1, = = What's the difference between equals ()?
= = is to judge whether two variables or instances point to the same memory space, and equals () is to judge whether the values of the memory spaces pointed by two variables or instances are the same.
= = indicates the comparison memory address, and equals () indicates the content of the comparison string.
= = refers to whether the references are the same, and equals () refers to whether the values are the same.
What is the role of final in 2.java?
Final is a keyword of Java and can be used in three places (modifier class, modifier method and modifier variable).
Feature: All references to the final keyword cannot be modified.
Decorative class: indicates that this class cannot be inherited.
Decorative method: indicates that the method cannot be overridden.
Modifier variable: indicates that a variable can only be assigned once, and the value cannot be modified (it can be understood as a constant).
3. & and & amp; differentiate
& is a bit operation, and the returned result is of type int. &&is a logical operation, and the returned result is Boolean. & No matter whether the previous conditions are right or not, the latter must be implemented. & amp& amp If the previous conditions are correct, the latter conditions will be implemented; if they are incorrect, they will not be implemented. In terms of efficiency, this is better.
4. If the hashCode () of two objects is the same, is equals () true?
Not necessarily.
Conversely, when equals is true, hashCode must be the same. Both the hashCode method and the equals method of the class can be overridden, and the return value is completely customized.
HashCode () returns the hash code value of the object; Equals () returns whether two objects are equal.
5. the difference between 5.string, stringbuffer and stringbuilder
The method of DString: final decoration, String class is to return newString. That is to say, any change to the String object will not affect the original object, and the modification to the string will generate a new object, which cannot be inherited.
StringBuffer: The operation methods of strings are synchronous to ensure thread safety. StringBuilder: Thread safety is not saved. You need to modify the string in the method body. You can modify strings by using new StringBuilder objects, appendreplace, delete and other methods of StringBuilder objects.
6. Can the 6.switch statement work on byte, long and String?
The switch can be used for char byte short int. Switches can be used as wrapper classes corresponding to char byte short int.
The switch does not apply to long double float Boolean values, including its wrapper class Long/Double.
Switches can be string types, and strings (jdk 1.7).
Acting on a string).
Switches can be enumeration types.
(1) What is the difference between the continuing education bases of the School of Continuing Education of Southwest University?