The operation rule of the '||' sign is the initialization of the original data and its wrapper class when creating a new object

 

In java, "||" is used to connect two judgment sentences, which is equivalent to "or". It has a feature that once the previous condition of the symbol is established, the latter condition is directly ignored. Such as:

               String str = null;
		if(str==null || str.equals("")){
			System.out.println("succece");
		}

 Here it will output success. Because str==null is true skip directly. Otherwise, the equals method of str is executed, because str is null and an exception will be thrown

 

 

If a class has a primitive data class attribute such as int, then the attribute has an initialization value of 0 when a new object is initialized. null if Integer

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326175440&siteId=291194637