소 백 학 자바

10227 단어
목차
1. 자바 환경 설정 2, 자바 코드 규범 3, 자바 노트 4, 자바 프로그램 작성
자바 환경 설정
1. 자바 다운로드 에 필요 한 JDK (내 가 다운로드 할 때 1.8 버 전) 주소: 주소 JDK 2, 다운로드 IDEA 주소: IDEA 주소 3, 등록 서버 작성http://idea.iteblog.com/key.php
자바 코드 규범
1、java        ,         
2、java       
(1)   、  、   、$  、         (       、   )
(2)     
(3)    java                 goto
(4)  java              System
(5)         ,     
3、         '


자바 노트
  :          
     :      ,            ,      ,       ,             
     :1、            2、      3、                   
     :                  1:    /  :       {}    (   )2:    :                        
   :1、    (          )2、    (           ,      }  )
  :1、                 ,       2、       ,           3、             4、               
     : oc  ,         = boolean   ? 1: 2(  :boolean      ture,            1,   false            2)
      (method)  (function)              : 
JAVA     :1、              
       : static     ,        ,             “.”  ,         new  2、java    main    jvm(java   )    ,       jvm    ,  main    。
java       :[   ]          ([  1,  2]){
       :
    [                ,    return ];
}
      :
     :public,static        ,          ,     static    
       :            ,         ,            ,             ,       void   ,       。
      :        ,      ,     ,        ,         。
      :         ,        ,          ,         。
      :    ==     +     +     
      :    ==    +                         (eg:doWork(int a,int b))                     。
     :   {}    ,              
     :1、       return     2、   :           ,         void     3、  :       
            ,                      
      :              ,        
      :
              ?
                ?
           :                ,                   ,       void    ,          ,                       。
          eg:     ,             ,        ,          
          ?
           :              ,          ,          ,         。
          eg:     ,                     ,         ,           
        :1、  :      ,                ,                2、                            。3、  :“”     (  :   ,          :        )⚠️:               ,            .             
  :getSum(1,2); /*                       */getSum(1.2,1.1);/*  double*/ (        ,        ,          )

JVM    ,                     
             :                 .
             :       native    
        java   :  java         ,                             ,   ,    ,       ⚠️:           ,               (    )        ,           。
        java :               ,         ,                  (  new   ,                )
           :         ,             ,  ,                  (                             )
         :    ,           ,                      0x******
         :    ,new           ,                16     0x********,               ,      ,           。

GC(Garbage Collection):     :
        java         :     ,                 jvm           ,            (         )        .⚠️ java      ,            ,                 ,            。

     :
          :       ,    ,                              ,                      。                 ,               ,   0  ,   1,   excel     ,    ,       

      :byte short int long float double char boolean
      :       
     :
        1:       []    ; int[] ages;       
        2:           [];int ages[];    
      ⚠️:         ,    4             

       :
           :                      ,            
              :      []     = new      [] {  1,  2,  3,........};
            int[] num = new int []{1,3,5,7,9};
                 (           ,          ):int [] num =  {1,3,5,7,9};
            int [] num = new int[]{1,3,4,5}; (1、    int       2、      3、          num  )
            System.out.println(num.length);
            num =  new int[]{2,4,8};
            System.out.println(num.length);
                             :                ,         1345,         num                 1345,     new     ,  248 ,      num               ,    num      ,       num  248,    
           :
                          (    )                 .
               :       []     = new       [length];
             eg.:int [ ] args = new int [100];
             /*          */
            int [] num = new int[3];
            System.out.println(num.length);
            num = new int[5];
            System.out.println(num.length);
                            :                    ,               。  num                    。      num        (    3    5)
                        ,           ?
              :                    ,                  。
      ⚠️:            ,                   ,              ,    ,                
      ⚠️:                     
       :
      1、    :        =      [index];
      2、    :   [index] =  ;
      3、    :    for  
      4、    :   .length;length    ,    
      5、    : 0  ,    ,[0,   .length-1];
    :
/*final                     */
        final  int bill = 100;
/*          */
     0           0X    
           ,         ,                 (  :float   long               float   ,  float    )
          double    float      float    1.0    F,  1.0F。
     :/*            long   */
      /*    */
       int d =  (int)Math.round(-10.9);
       System.out.println(d);
      :
          ' '     “  ”
    :      \"\"         
        System.out.println("     \"5 7\"");
&& ||:
    &&      true  true  ||      false  false
         : !> && > ||
    : while   do while  do while           while         
          int type = 1;
            do {
                type ++ ;
            }while (type>3);
            System.out.println(type);
break continue   :
        break             continue                 。       break        .                ?             ,  break        。   for         。  break   ; OK 。
  :
                : 
                 :(int)(Math.random()*100)
     int [] hour = new int[(int)(Math.random()*100)];
        System.out.println(hour.length);
        for(int i =0 ;i

자바 방법 호출
public class Main {    public static void main(String[] args) {        System.out.println("Hello World!");        Main.doWork();    }    static void doWork(){        System.out.println("     ");//        }    public static void work(){        System.out.println("        ");    }}


자바 프로그램 작성
public class Main {    public static void main(String[] args) {        System.out.println("     ");    }}

삼원 식
public class Main {    public static void main(String[] args) {        double num = 3.51;        int num1 = (int)num;        double num2 = num - num1;        int result = num2>= 0.5 ? num1+1 :num1;        System.out.println(result);    }}

java 매개 변수 없 음 반환 값 없 음 매개 변수 없 음 반환 값 있 음 매개 변수 없 음 반환 값 있 음 demo 있 음
public class Main {    public static void main(String[] args) {        System.out.println("Hello World!");        Main.doWork();        Main.p();/*  */        Main.pValue("hello");//          int age =  Main.getAge();        System.out.println(age);        int sum = Main.getSum(3,4);        System.out.println(sum);    }    /*       */    /*   :          ---------*/    static void p(){        System.out.println("---------");//        }    /*        */    /*  :     */    static void pValue(String va){        System.out.println(va);//    string      }    /*        */    /*  :      */    static int getAge(){        return  17;    }    /*       */    /*      */    static int getSum(int a,int b){            return  a+b;    }    static void doWork(){        System.out.println("     ");//        }    public static void work(){        System.out.println("        ");    }}  

자바 문자 보 내기 기능 구현 (참조)
public class Main {    public static void main(String[] args) {        System.out.println("Hello World!");        int ret = sendMsg("10086","  ");        int temp = sendMsg("10010","     ");    }    /*           */    //     sendMsg    /*0:           1:          2:          * */    static int sendMsg(String phoneNum, String content){        /*         */        return  int     ;            }}
  

자바 로그 인 기능 구현
/*      */static boolean login (String username,String password){    /*               */    /*     bool    */        }

자바 재 귀 알고리즘 구현
    ,         ,          ,    :F(0)=0,F(1)=1,Fn = F(n-1)+F(n-2),   F(5)  ,     ?
    public class Main {    public static void main(String[] args) {        System.out.println("Hello World!");        int ret = fn(6);        System.out.println(ret);    }    static int fn (int n){        if (n==0){            return  0;        }        else if(n==1){            return  1;        }else {            return fn(n-1)+fn(n-2);        }    }}
              
sout     
psvm      

자바 프로그램 에서 자주 발생 하 는 오류 메시지 (콘 솔)
java.lang.NullPointerException----                (                       )
ArrayIndexOutOfBoundsException------         (              ,              )


문자열 맞 춤 법
Scanner in = new Scanner(System.in);
        /*in.nextLine       in   nextLine    ()          .              +               ,                           。                         */
//        System.out.println(in.nextLine());
        /*        */
        System.out.println("Answer:"+in.nextLine());

간단 한 감법 연산
public class Hello {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        /*     */
        int price = 0;
        /* = */
        /*      */
        price = in.nextInt();
        int chage = 100-price;
        System.out.println(chage);

    }
}

좋은 웹페이지 즐겨찾기