java "+" operator

/ * 
Four calculation plus good "+" There are three common usage 

    1, the value for it, and that is an addition 
    2, char is for character, before calculating the char would be promoted to become int calculation and then 
    3 for character string string (initials, not keyword), the plus sign represents a string connecting operation of 
    any data type, and when the connection string, the result will become the string 
* / 
public  class Demo01Puls {
     public  static  void main ( string [] args) {
         // basic string type
         // data type data variable name = value; 
        string str1 = "the Hello" ; 
        System.out.println (str1); // the Hello 
        
        string str2 = "Java" ;
         // String + int ---> String 
        System.out.println (str2 + 20);   //java20 
        
        // priority issues
         // String + int + int 
        System.out.println (str2 20 is + 30 +); // java2030 
        System.out.println (str2 + (20 is + 30));   // Java50 
        
    } 
}

 

 

If infringement, delete the contact

Guess you like

Origin www.cnblogs.com/spp666/p/11672154.html
Recommended