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

    Also consider java.text.MessageFormat, which uses a related syntax having numeric argument indexes. For example, String aVariable = "of ponies"; String string = MessageFormat.format("A …

  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. Java: how to initialize String[]? - Stack Overflow

    7 String[] errorSoon = new String[n]; With n being how many strings it needs to hold. You can do that in the declaration, or do it without the String [] later on, so long as it's before you try use …

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

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

  6. 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, 2 months ago Viewed 40k times

  7. Change string in Java - Stack Overflow

    Once you have created a string you cannot later change that string object. Java uses pass-by-value, not pass-by-reference. When you assign a new value to s in your method it only …

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

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

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