JAVA基礎初学のデータ型及び演算子アルゴリズム

11395 ワード

JAVAの基础の初学のデータ型と演算子のアルゴリズムを独学して、内容はデータ型とその定义の演算子とそのアルゴリズムを含んでほとんどすべての行はすべて注釈と知识の点の小さい结び目が兴味の初心者が理解することができます!
//          
public class Holle {
    public static void main(String[] args){
    //8       
    byte a1 = 127;//   [-128,-127],    
    short a2 = 128;//    
    int a3 = 125555;//    
    long a4 = 124L;//  L  long    ,    
    float a5 = 1.1F;//  F  float    
    double a6 = 1.11D;//  D  double    
    char a7 = ' ';//char ''       ,''   2   ,       2   .
    System.out.println(a1);//127
    System.out.println(a2);//128
    System.out.println(a3);//125555
    System.out.println(a4);//124
    System.out.println(a5);//1.1
    System.out.println(a6);//1.11
    System.out.println(a7);// 
    //String       ,    
    String a8 = "7+5" ;//String   ""       
    System.out.println(7 + a8);//   a8 7+5
    //       
    String a9 = "\"7+5\"";//            \  
    System.out.println(7 + a9);
    /*
     *       :
     *      ,           ,    int  
     *        ,                ,           
     *  int    +double     ,         double  ,
     *               ,                ,    
     * String       ,""         ,          ,        ,     \   
     */
    System.out.println("----------------------------------------------------------------");



    //     
    int b1 = 15;//    b1    15
    //       : b1=b1++     (        ++    )b1  1,  b1    16
    int b2 = b1++;// ++   , b1    ,        , b2==b1    ==15
    System.out.println(b1);//16
    System.out.println(b2);//15

    int b4 = 15;//    b4    15
    int b3 = ++b4;//++   ,       ,b4=++b4, ++b4==15+1==16,16   b3
    System.out.println(b4);//16
    System.out.println(b3);//16
    /*
     *       
     *       ,            ,          
     * %  ,            ,
     *   (++)  (--),++result result++   result+1,                ,        .
     */
    System.out.println("----------------------------------------------------------------");

    //     (=,+=,-=,*=,/=,%=)
    int c1 = 3;
    int c2 = 2;
    c1 += c2;//     c1=c1+c2,    
    System.out.println(c1);//5
    System.out.println(c2);//2
    System.out.println("----------------------------------------------------------------");

    //     (==,!=,,<=,>=,instanceof,       )
    int d1 = 10;//   A
    int d2 = 12;//   B
    boolean result = d1 >= d2;
    System.out.println(result);//       false true.     false.
    /*
     *     :boolean result =    A           B;  
     * instanceof         ,            
     */
    System.out.println("----------------------------------------------------------------");   

    //     (&,|,^,!,&&,||,         )
    boolean result1 = true & true;//  true
    boolean result2 = false & true;// false
    boolean result3 = true & false;// false
    boolean result4 = false & false;// false
    System.out.println(result1);//true
    System.out.println(result2);//false
    System.out.println(result3);//false
    System.out.println(result4);//false 

    System.out.println("----------------------------------------------------------------");  

    boolean result5 = true | true;// |  OR, ,         true ,    true
    boolean result6 = false ^ true;// ^    ,XOR,  A B    ,    true,   false
    boolean result7 = !false;// !    ,Not,true   false
    boolean result8 = false && false;// &    ,      .    , A false,     B   
    boolean result9 = true|| false;// |    ,      ,    , A true,     B   
    System.out.println(result5);//true
    System.out.println(result6);//true
    System.out.println(result7);//true
    System.out.println(result8);//false
    System.out.println(result9);//true
    /*
     *       :
     *         ( || )
     *     B           ,       
     *   :boolean result = true || (1/0=1);         
     */
    System.out.println("----------------------------------------------------------------");  



    //     (        ,          )
    int e1 = 5;
    int e2 = 7;
    int num1 = e2 - e1;
    int num2 = num1 >= 1.5 ? e1 : e2;
    System.out.println(num2);
    /*
     *     :
     *     :boolean    ?  1 :  2;
     * num1 >= 1.5   boolean     
     *   num1   boolean      ,       ,        
     */
    System.out.println("----------------------------------------------------------------");  



    //    (&,|,^,~,<>,>>>,     ,    :0  false,1  true)
    int f1 = 3;
    int f2 = 2;
    /*
     *      :
     *     0b00000011  =3
     *   & 0b00000010  =2
     *   ------------
     *     0b00000010  =2
     */
    System.out.println(f1 & f2);//      1 ,     1,   0
    /*
     *      :
     *     0b00000011  =3
     *   | 0b00000010  =2
     *   ------------
     *     0b00000011  =3
     */
    System.out.println(f1 | f2);//       1  1,    1
    /*
     *     0b00000011  =3
     *   ^ 0b00000010  =2
     *   ------------
     *     0b00000001  =1 
     */
    System.out.println(f1 ^ f2);//       0,   1
    /*
     *     0b00000011  =3
     *   ^ 
     *   ------------
     *     0b11111100  =-4
     */
    System.out.println(~f1);//        1  0,0  1

    }
}

“`