Learn to program the Java tutorial of the string class published, welcome through the xuebiancheng8.com to visit
The string class in Java class should be the most use of a class, we are inseparable from the string class, always in use, interview often test, for example, ask the String class is not the basic data type. The answer is no, the string class is not a basic data type, but the use of the string class and the base data type is very similar.
Let's look at the use of the string class.
String str= "abc";//defines a string ABC
String str1= new String ("abc");//also defines a string
if (STR==STR1) {
System.out.println ("true");
}else{
System.out.println ("false");
}
What is the output of the above program?
The answer is false.
= = The address is compared. Here the first ABC is saved in a constant pool. The second ABC is in the heap space, so = = compares the address differently
This compares whether the strings are equal in equals.
For more information, please visit xuebiancheng8.com
The specific URL is
Http://xuebiancheng8.com/play/goodgoodstudy_101_daydayup.html
Learn Java tutorials in the String class