About 193,000 results
Open links in new tab
  1. java - How to including variables within strings? - Stack Overflow

    String string = String.format("A String %s %2d", aStringVar, anIntVar); I'm not sure if that is attractive enough for you, but it can be quite handy. The syntax is the same as for printf and …

  2. 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 …

  3. Use string in switch case in java - Stack Overflow

    Apr 20, 2012 · Simply because Java7+ code using switch over string compiles to code assuming exactly that invariant property. So it can’t change in future versions and it’s even simpler to see …

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

    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 …

  5. 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 …

  6. 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.

  7. Java String variable setting - reference or value? - Stack Overflow

    String is a class, so a String variable is a reference. But it's a language intrinsic, in the sense that Java has special handling and syntax for it, which is why you can do things like your example.

  8. How do I concatenate two strings in Java? - Stack Overflow

    I am trying to concatenate strings in Java. Why isn't this working? public class StackOverflowTest { public static void main (String args []) { int theNumber = 42; System.out.

  9. java - How to println a string and variable within the same …

    Oct 16, 2013 · How to println a string and variable within the same parameters Asked 12 years ago Modified 2 years, 3 months ago Viewed 40k times

  10. How do you initialize a String in java? - Stack Overflow

    The problem is that the only variable on a project I am doing is a String and I am not sure whether I should be initializing it in the declaration (as a global variable?), in an setter instance method …