About 165,000 results
Open links in new tab
  1. Java: how to initialize String []? - Stack Overflow

    Apr 1, 2010 · In Java 8 we can also make use of streams e.g. String[] strings = Stream.of("First", "Second", "Third").toArray(String[]::new); In case we already have a list of strings (stringList) …

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

  3. Global variables in Java - Stack Overflow

    Jun 6, 2014 · TO DECLARE A VARIABLE AS GLOBAL. 1.Mark the variable as public static final While declaring. TO DECLARE A METHOD AS GLOBAL. 1. Mark the method as public static …

  4. best practise to use string in java - Stack Overflow

    Dec 12, 2017 · It all depends on where are you creating string variables. If you are creating string variable as in instance variable of class then you don't need to initialize it, because java will …

  5. Java String declaration - Stack Overflow

    First one will create new String object in heap and str will refer it. In addition literal will also be placed in String pool. It means 2 objects will be created and 1 reference variable. Second …

  6. Does it make sense to define a final String in Java?

    Nov 23, 2013 · The String object is immutable but what it is is actually a reference to a String object which could be changed. For example: String someString = "Lala"; You can reassign …

  7. Java - Create a new String instance with specified length and filled ...

    Nov 26, 2009 · This creates a String with length-times '0' filled and replaces then the '0' with the charToFill (old school). String s = String.format("%0" + length + "d", 0).replace('0', charToFill); …

  8. java - How to create JSON Object using String? - Stack Overflow

    Nov 21, 2013 · I want to create a JSON Object using String. ... Creating JSONObject from string in Java (org.json ...

  9. java - Declaration of a variable of type String - Stack Overflow

    Sep 12, 2017 · I should note that String objects, specifically, are special in Java, for a couple of reasons: They're one of the very few objects for which we have a literal notation ( "this is a …

  10. What is the correct way to declare a boolean variable in Java?

    Aug 1, 2016 · Further, we initialize the boolean variable to false to hold an initial default value which is false. In case you have declared it as instance variable, it will automatically be …