java 基礎知識整理

  1. java 基本數據類類型有哪些?

八種基本類型

Byte         比特型

Short       短整型

Int            整型

Long        長整型

Float        單精度浮點型

Double    雙精度浮點型

Char        字符型

Boolean  布爾型


2.&和&&的區別

&和&&的區別是,&會執行兩邊,不管第一個是否成立
&&只會執行一邊,如果第一個條件爲假,則不會走第二個條件


3.if和switch分支語句的區別

switch適合固定分支

if適合範圍內分支


4.while和do-while的區別

while先判斷後執行

do-while先執行後判斷


5.Eclipse常用快捷鍵有哪些?

ALT/                       補全命令

ctrl+shift+o           導包快捷鍵

ctrl+shift+f            代碼格式化快捷鍵

Ctrl/                     多行註釋反註釋

/**enter               註釋符



6.編程實現九九乘法表

package com.lenovo.www.commo;

public class JiuJiu {
public static void main(String[] args) {
    for(int i=1;i<=9;i++) {
        for(int j=1;j<=i;j++) {
            System.out.print(i+"*"+j+"="+j*j+"\t");
        }
        System.out.println();
    }
}

}

6判斷閏年

package com.lenovo.www.commo;

import java.util.Scanner;

public class NunnianPanduan {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int year = scan.nextInt();
        if (year % 400 == 0 && year % 100 == 0) {

            System.out.println("是閏年");

        } else if (year % 4 == 0 && year % 100 != 0) {
            System.out.println("是閏年");

        }else {
            System.out.println("不是閏年");
        }

    }
}









發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章