&does not haveShort-circuit nature, for if (str! = null &&!str.equals ("")) expression, when STR is null. The following expressionwill still runSothere will be NullPointerException,In addition,,& can also be used as bit operators.
Whether the switch statement can function on a byte, whether it can function on a long, whether it can function on a string?
在switch(expr1)中。expr1能够是 byte, char, short,int 以及它们的包装类 Byte ,Character, Short, Integer,还有enum(枚举)、String(JavaSE 7添加的)
The Examiner Net Http://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html
Third, when modifying a variable with Finalkeyword. Is the reference immutable, or does the referenced object not change?
When you use Finalkeyword to decorate a variable, the reference variable cannot be changed, and the contents of the object to which the reference variable is pointing can be changed. For instance, for example, the following statement:
Final StringBuffer a=new StringBuffer ("immutable");
Run for example the following statement will report a compile-time error:
A=new StringBuffer ("");
However, running such as the following statement is possible by compiling:
A.append ("broken!");
When someone defines a method's parameters, it may want to use the following form to prevent the internal changes in the method from passing in the Parameter object:
public void Method (final stringbuffer param)
{
}
In fact, this is not possible, within the method can still add such as the following code to modify the parameters of the object:
Param.append ("a");
four, when you run string str=new string ("abc"). , how many string objects did you create?
If we search the answer online, almost all of the answers are as follows:
If the string pool does not have ABC, it creates an ABC object in the string pools, and then creates an ABC object in the heap, returning the address of the ABC object in the heap to STR, which is the case of creating 2 objects, or simply creating an ABC object in the heap.
But. I saw a video of the commentary today. He says that no matter what the situation is, just create a string object. ABC objects are not created in the string pool, regardless of the circumstances. Arguments:
String s1= "HJK"; String S2=s1.intern (); The function of intern () is to assume that there is a S1 string value "HJK" in the constant pool, and //returns the String object. Otherwise, add "HJK" to the constant pool and return the string object. System.out.println (S2==S1); TrueString s3=new String ("abc"); String S4=s3.intern (); System.out.println (S3==S4); FalseString S5=s3.intern (); System.out.println (S5==S4); True
Another reference: Java face question video commentary Http://study.163.com/course/courseMain.htm?courseId=519065#/courseMain