Sunday, April 21, 2019

java - New String vs String s = "something" , what's the difference ?

Consider the code :



public class Strings {


public static void createStr()
{
String s1 = new String("one");
String s2 = "one";

System.out.println(s1);
System.out.println(s2);
}


public static void main(String args[])
{
createStr();
}

}


What's the difference between String s1 = new String("one"); and String s2 = "one"; ?

No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...