About 51 results
Open links in new tab
  1. How do I compare strings in Java? - Stack Overflow

    Apr 2, 2013 · String.contentEquals () compares the content of the String with the content of any CharSequence (available since Java 1.5). Saves you from having to turn your StringBuffer, etc into a …

  2. What is the difference between String[] and String... in Java?

    What's actually the difference between String[] and String... if any? The convention is to use String[] as the main method parameter, but using String... works too, since when you use varargs you can call …

  3. Java: how to initialize String []? - Stack Overflow

    9 I believe you just migrated from C++, Well in java you have to initialize a data type (other then primitive types and String is not a considered as a primitive type in java ) to use them as according to their …

  4. java - String.equals versus == - Stack Overflow

    Let's see it happen in Java terms. Here's the source code of String's equals() method: It compares the Strings character by character, in order to come to a conclusion that they are indeed equal. That's …

  5. difference between new String[]{} and new String[] in java

    String array = new String[10]{}; //The line you mentioned above Was wrong because you are defining an array of length 10 ([10]), then defining an array of length 0 ({}), and trying to set them to the same …

  6. How do I split a string in Java? - Stack Overflow

    Nov 20, 2016 · String string = "004-034556"; String[] parts = string.split("-"); String part1 = parts[0]; // 004 String part2 = parts[1]; // 034556 Note that split 's argument is assumed to be a regular expression, …

  7. How to format strings in Java - Stack Overflow

    Primitive question, but how do I format strings like this: "Step {1} of {2}" by substituting variables using Java? In C# it's easy.

  8. java - How to convert a char to a String? - Stack Overflow

    Nov 17, 2011 · String.valueOf(char) "gets in the back door" by wrapping the char in a single-element array and passing it to the package private constructor String(char[], boolean), which avoids the …

  9. How to initialize List<String> object in Java? - Stack Overflow

    Nov 15, 2012 · We created soyuz-to to simplify 1 problem: how to convert X to Y (e.g. String to Integer). Constructing of an object is also kind of conversion so it has a simple function to construct Map, List, …

  10. Does Java have support for multiline strings? - Stack Overflow

    StringBuilder.append () is preferable to plus when repeatedly adding to a string because every time you do string1 + string2 you're allocating a new string object and copying the characters from both of the …