初級代碼

Day01

class 例子{

?? public static void main(String[] args){?

???? System.out.println("你好~~~");

?? }

}

Day02

public classDemo {

?? public static void main(String[] args){?

?? ?System.out.println("Hello");

???? System.out.println(3.02 - 2.89);

?? }

}

2闷叉、

public class OperatorDemo{

?? public static void main(String[] args){

???? /*

???? int i = 5;

???? int j = 7;

???? int k = i + j;

???? */

????

???? // int i = 5;

???? //表示先將i的值5取出來,然后+7畜挥,最后將結(jié)果再賦值給i

???? // i = i + 7;

???? /*

???? byte b1 = 5;

???? byte b2 = 7;

???? byte b = (byte)(b1 + b2);

???? */

???? /*

???? byte b = 5;

???? b = b + 7;

???? System.out.println(b);

???? */

???? // int i = 4200;

???? // double d = i / 1000 * 1000;

???? // double d = i / 1000.0 * 1000;

???? // System.out.println(d);

???? // System.out.println(5 / 0);

???? // System.out.println(5 / 0.0);

???? // System.out.println(-5.2 / 0);

???? System.out.println(0 / 0.0);????????????

?? }

}

3

public classTypeDemo {

?? public static void main(String[] args){

???? System.out.println(10);

???? int i = 6;

???? int j = 7;

???? //當(dāng)表示一個比較大的整數(shù)的時候,可以使用_進行分位症革,但是需要注意的是這種寫法是從JDK1.7出現(xiàn)的

???? int k = 5_482_637;

???? System.out.println(k);

???? long l1 = 15L;

???? System.out.println(l1);

???? float f1 = 5.87f;

???? float f2 = 2.854F;

????

???? char c = 'a';

???? //表示用utf-16編碼形式來寫這個字符

???? char c2 = '\ua4f3';

???? System.out.println(c);

???? System.out.println(c2);

???? System.out.println('\\');

????

???? boolean b = false;

???? System.out.println(b);

????

?? }

}

3

public classTypeDemo2 {

?? public static void main(String[] args){

???? /*

???? byte b = 125;

???? int i = b;

???? System.out.println(i);

???? */

????

???? // 1.23456794E9

???? // xey表示x*10^y

?? ?? /*

???? int i = 1234567890;

???? float d = i;

???? System.out.println(d);

???? */

????

???? /*

???? double d = 3e5;

???? System.out.println(d);

???? */

???? /*

???? float f = -25;

???? System.out.println(f);

???? */

????

???? /*

???? char c = 'a';

???? int i = c;

???? System.out.println(i);

???? */

????

???? /*

???? int i = 135;

???? byte b = (byte)i;

???? System.out.println(b);

???? */

????

???? /*

???? byte b = 127;

???? byte b2 = (byte)(b + 1);

???? System.out.println(b2);

???? */

????

???? double d = -6.9;

???? int i = (int)d;

???? System.out.println(i);

?? }

}

4罗晕、

public classVariableDemo {

?? public static void main(String[] args){

????

???? int i = 6;

???? System.out.println(i);

?? }?

}

DAY 03

1

importjava.util.Scanner;

public classIfDemo {

?? public static void main(String[] args){

???? Scanner s = new Scanner(System.in);

???? int i = s.nextInt();

????

???? //判斷這個數(shù)字是否是3的倍數(shù)

???? if(i % 3 == 0)

??????? System.out.println(i + "是3的倍數(shù)");

?? }

}

2憔儿、

importjava.util.Scanner;

public classIfElseDemo {

?

?? public static void main(String[] args){

??

???? Scanner s = new Scanner(System.in);

???? int i = s.nextInt();

????

???? if(i % 2 == 1){

??????? System.out.println(i + "是一個奇數(shù)");

???? } else {

??????? System.out.println(i + "是一個偶數(shù)");

???? }

?? }

}

3忆植、

importjava.util.Scanner;

public classIfElseExer {

??

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

???? int i = s.nextInt();

???? int j = s.nextInt();

???? int k = s.nextInt();

????

???? /*

???? if(i < j){

??????? if(i < k){

????????? System.out.println(i);

??????? } else {

????????? System.out.println(k);

??????? }

???? } else {

??????? if(j < k){

????????? System.out.println(j);

??????? } else {

????????? System.out.println(k);

??????? }

???? }

???? */

???? int min = i;

???? if(min > j)

??????? min = j;?

???? if(min > k)

??????? min = k;????

???? System.out.println(min);

?? }

??

}

4

importjava.util.Scanner;

public classIfElseExer2 {

??

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

???? double weight = s.nextDouble();

????

???? double price = 0;

???? if(weight < 0){

??????? System.out.println("不合法的重量!3耀里!");

???? } else {

??????? if(weight <= 20){

????????? price = weight * 0.35;

??????? } else {

????????? if(weight <= 100){

???????????? price = 20 * 0.35 + (weight - 20) *0.5;

????????? } else {

???????????? price = 20 * 0.35 + 80 * 0.5 +(weight - 100) * 0.8;

????????? }

??????? }

???????

???? }

????

???? System.out.println(price);

????

?? }

??

}

5

importjava.util.Scanner;

public classIfElseIfDemo {

??

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

?? ?? doubleweight = s.nextDouble();

????

???? double price = 0;

????

???? if(weight < 0){

??????? System.out.println("非法的重量J懊ァ7肟妗!");

???? } else if(weight <= 20){

??????? price = weight * 0.35;

???? } else if(weight <= 100){

??????? price = 7 + (weight - 20) * 0.5;

???? } else {

??????? price = 47 + (weight - 100) * 0.8;

???? }

????

???? System.out.println(price);

?? }

}

6痪枫、

importjava.util.Scanner;

public classIfElseIfExer {

??

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

???? int month = s.nextInt();

????

???? if(month < 1 || month > 12){

??????? System.out.println("Illegal month!!!");

???? } else if(month > 2 && month< 6){

??????? System.out.println("Spring");

???? } else if(month > 5 && month< 9){

??????? System.out.println("Summmer");

???? } else if(month > 8 && month< 12){

??????? System.out.println("Autumn");

???? } else {

??????? System.out.println("Winter");

???? }

????

????

?? }

??

}

?

7织堂、

public classOperatorDemo {

??

?? public static void main(String[] args){

????

???? /*

???? int i = -9;

???? int j = 4;

???? System.out.println(i % j);

???? */

???? // System.out.println(5 % 1.4);

???? int i = 7;

???? //相當(dāng)于在原來的基礎(chǔ)上來自加1

???? //先將i的值7取出來標(biāo)記為結(jié)果,然后i自增為8奶陈,最后再將7賦值給j

???? // int j = i++;

???? //先將i自增為8易阳,然后再將i的值賦值給j

???? // int j = ++i;

???? //先將i的值7取出來參與后續(xù)運算,然后i自增為8吃粒,用7參與乘法運算潦俺,結(jié)果就是14,最后將計算的14賦值給j

???? // int j = i++ * 2;

???? //先將i自增為8徐勃,然后將8取出來參與乘法運算事示,結(jié)果結(jié)果是16

???? int j = ++i * 2;

???? System.out.println(i);

???? System.out.println(j);

?? }

??

}

8

public classOperatorDemo2 {

??

?? public static void main(String[] args){

????

???? /*

???? byte b = 127;

???? //在底層自動做了一次強制轉(zhuǎn)換

???? b++;

???? System.out.println(b);

???? */

????

???? /*

???? char c = '0';

???? System.out.println(c + 3);

???? */

????

???? // byte b = 130;

???? // 3和5是兩個字面量僻肖,字面量在參與運算的時候會自動的優(yōu)化

???? //在編譯時期就會自動計算

???? // byte b = 8;

???? // byte b = 3 + 5;

???? // System.out.println(b);

????

???? // byte i = 5;

???? // i = i + 3;

???? // i += 33;

???? // i = i % 5;

???? // i %= 5;

???? // System.out.println(i);

????

???? // int i = j = k = 10;

???? // int i, j, k;

???? // i = j = k = 10;

????

???? /*

???? int i = 5;

???? i += i *= i -= 3;

???? System.out.println(i);

???? */

????

???? /*

???? System.out.println(3 == 5);

???? System.out.println(3 != 5);

???? int i = 5;

???? System.out.println(3 < i < 7);

???? */

????

???? /*

???? int i = 5, j = 7;

???? // boolean b = i++ >= 6 && j++> 3;

???? boolean b = j++ > 3 || i++ > 4;

???? System.out.println(i);

???? System.out.println(j);

???? System.out.println(b);

???? */

????

???? // int i = 3, j = 5, k = 6;

???? // boolean b = i++ > 0 || j++ > 5&& k++ < 10;

???? /*

???? boolean b = i++ > 5 && j++ >4 || k++ > 3;

???? System.out.println(i);

???? System.out.println(j);

???? System.out.println(k);

???? System.out.println(b);

???? */

????

???? int i = 5, j = 7, k = 4;

???? // int max = i > j ? i : j;

???? // System.out.println(max);

???? // i > j ? System.out.println(i) :System.out.println(j);

???? //三元表達式的嵌套

???? int max = i > j ? (i > k ? i : k) :(j > k ? j : k);

???? System.out.println(max);

?? }

}

?

9察郁、

public classOperatorDemo3 {

?

?? public static void main(String[] args){

????

???? //如果算術(shù)>關(guān)系厉颤,先計算1+3=4欢顷,最后比較3>4肤粱,結(jié)果為false

???? //如果關(guān)系>算術(shù),先計算3>1=true,然后true+1無法計算揉稚,會報錯

???? // System.out.println(3 > 1 + 3);

????

???? //如果關(guān)系>邏輯秒啦,先計算3>4=false,然后再計算true&false=false

???? //如果邏輯>關(guān)系,先計算true&3,無法計算搀玖,會報錯

???? // System.out.println(true & 3 > 4);

????

???? // System.out.println(1 & 6 + 3);

????

???? // System.out.println(2 << 3 > 3);

???? // System.out.println(2 & 3 > 2);

???? // System.out.println(2 << 3 + 3);

???? // System.out.println(~3 + 3);

???? // int i = 3, j = 5;

???? // System.out.println(i < j ? i : j +10);

???? // boolean b = i < j ? i : j > 4;

???? // System.out.println(i < j ? i : j ^5);

????

???? int i = 5;

???? // i = ~i++;

???? i = ~++i;

???? System.out.println(i);

?? }

}

10余境、

importjava.util.Scanner;

public classOperatorExer {

?? public static void main(String[] args){

???? Scanner s = new Scanner(System.in);

???? //從控制臺獲取一個小數(shù)

???? double score = s.nextDouble();

???? int i = s.nextInt();

????

???? char level = score >= 90 ? 'A' : (score>= 80 ? 'B' : (score >= 70 ? 'C' : (score >= 60 ? 'D' : 'E')));

???? System.out.println(level);

?? }

}

DAY 04

1

importjava.util.Scanner;

public classWhileExer {

?

?? public static void main(String[] args){

????

???? // 1.求1-100以內(nèi)所有的奇數(shù)的和

???? /*

???? //記錄和

???? int sum = 0;

???? int i = 1;

???? while(i <= 100){

??????? sum += i;

??????? i += 2;

???? }

???? System.out.println(sum);

???? */

????

???? // 2.打印100以內(nèi)能被3整除而不能被7整除的數(shù)字

???? //思路:先獲取所有的3的倍數(shù)灌诅,然后再判斷這個倍數(shù)能否被7整除

???? /*

???? int i = 0;

???? while(i <= 100){

???????

??????? //判斷能否被7整除

??????? if(i % 7 != 0)

????????? System.out.println(i);

???????

??????? i += 3;

???? }

???? */

????

???? // 3.輸入一個數(shù)字芳来,輸出這個數(shù)字是一個幾位數(shù)

?? ?? //思路:看能除以幾次10

???? /*

???? Scanner s = new Scanner(System.in);

???? int n = s.nextInt();

???? int count = 0;

???? while(n != 0){

??????? n /= 10;

??????? count++;

???? }

???? System.out.println(count);

???? */

????

???? // 4.輸入一個數(shù)字,輸出這個數(shù)字的所有的因數(shù)

???? Scanner s = new Scanner(System.in);

???? int n = s.nextInt();

???? int i = 1;

???? while(i <= n){

???????

??????? if(n % i == 0)

????????? System.out.println(i);

???????

??????? i++;

???? }

????

?? }

?

}

2

public classWhileDemo {

?

?? public static void main(String[] args){

????

???? /*

???? //表示次數(shù)

???? int count = 0;

???? while(count < 10){

??????? System.out.println("Hello");

??????? count++;

???? }

???? */

????

???? /*

???? //打印1-10

???? int i = 1;

???? while(i <= 10){

??????? System.out.println(i);

??????? i++;

???? }

???? */

????

???? //求1-100的和

???? int sum = 0;

???? int i = 1;

???? // while循環(huán)的條件是必須寫的

???? while(){

??????? sum += i;

??????? i++;

???? }

???? System.out.println(sum);

????

????

?? }

?

}

3

importjava.util.Scanner;

public classSwitchCaseExer2 {

??

?? public static void main(String[] args){

????

???? //獲取年月日

???? Scanner s = new Scanner(System.in);

???? int year = s.nextInt();

???? int month = s.nextInt();

???? int day = s.nextInt();

????

???? //定義一個變量來記錄總天數(shù)

???? int sum = 0;

????

???? //根據(jù)月份確定到底要加上多少天

???? switch(month){

??????? case 12:sum += 30; //經(jīng)歷11月的30天

??????? case 11:sum += 31; //經(jīng)歷10月的31天

??????? case 10:sum += 30;

??????? case 9: sum += 31;

??????? case 8: sum += 31;

??????? case 7: sum += 30;

??????? case 6: sum += 31;

??????? case 5: sum += 30;

??????? case 4: sum += 31;

??????? case 3: //加上2月的天數(shù) - 平年和閏年的判斷

????????? if(year % 100 != 0 && year % 4== 0 || year % 400 == 0){

???????????? sum += 29;

????????? } else {

???????????? sum += 28;

????????? }

??????? case 2: sum += 31;

??????? case 1: sum += day;

???? }

???? System.out.println(sum);

????

?? }

??

}

4猜拾、

importjava.util.Scanner;

public classSwitchCaseExer {

??

?? public static void main(String[] args){

????

???? //獲取兩個數(shù)字和一個符號

???? Scanner s = new Scanner(System.in);

???? double m = s.nextDouble();

???? double n = s.nextDouble();

???? String symbol = s.next();

????

???? //根據(jù)符號確定要進行的運算

???? switch(symbol){

??????? case "+":

????????? System.out.println(m + n);

????????? break; //表示結(jié)束當(dāng)前的選項

??????? case "-":

????????? System.out.println(m - n);

????????? break;

??????? case "*":

????????? System.out.println(m * n);

????????? break;

??????? case "/":

????????? System.out.println(m / n);

????????? break;

??????? case "%":

????????? System.out.println(m % n);

????????? break;

??????? default:

????????? System.out.println("符號非法<瓷唷!关带!");

????????? break;

???? }

????

?? }

??

}

5

importjava.util.Scanner;

public classSwitchCaseDemo2 {

?

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

???? // int i = s.nextInt();

????

???? /*

???? int j = 0;

???? switch(i){

???????

??????? //如果沒有break侥涵,那么代碼從匹配的case開始,順次往下執(zhí)行宋雏,直到遇到break芜飘;

??????? case 0 : j += 3;

??????? case 2 : j += 6;break;

??????? case 1 : j += 4;break;

??????? case 3 : j += 7;break;

???????

???? }

????

???? System.out.println(j);

???? */

????

???? //輸入數(shù)字表示月份,然后輸出這個月份對應(yīng)的天數(shù)(平年)

???? // 31天:1 3 5 7 8 10 12

???? // 30天:4 6 9 11

???? // 28天:2

???? int month = s.nextInt();

???? switch(month){

??????? case 1:

??????? case 3:

??????? case 5:

??????? case 7:

??????? case 8:

??????? case 10:

??????? case 12:

????????? System.out.println(31);break;

??????? case 4:

??????? case 6:

??????? case 9:

??????? case 11:

????????? System.out.println(30);

????????? break;

??????? case 2:

????????? System.out.println(28);

????????? break;

??????? default:

????????? System.out.println("Illegalmonth!!!");break;

???? }

?? }

?

}

6磨总、

importjava.util.Scanner;

public classSwitchCaseDemo {

??

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

???? int n = s.nextInt();

????

???? switch(n){

??????? case 4:

????????? System.out.println("星期四");break;

??????? case 2:

????????? System.out.println("星期二");break;

??????? case 5:

????????? System.out.println("星期五");break;

??????? case 3:

????????? System.out.println("星期三");break;

??????? case 6:

????????? System.out.println("星期六");break;

??????? case 1:

????????? System.out.println("星期一");break;

??????? case 7:

????????? System.out.println("星期天");break;

??????? //只要其他的case都不符合則自動劃歸到default

??????? default:

????????? System.out.println("星期不合法`旅鳌!蚪燕!");break;

???? }?

?? }

}

7娶牌、

public classLoopExer {

?

?? public static void main(String[] args){

????

???? /*

???? for(int i = 1; i <= 9; i++){

???????

??????? for(int j = 1; j <= i; j++){

????????? System.out.print(j + "*" + i+ "=" + (i * j) + "\t");

??????? }

??????? System.out.println();

???????

???? }

???? */

????

???? /*

????????? *****

??????? ??*****

??????? ?*****

??????? ?*****

??????? *****

???? */

???? /*

???? for(int i = 1; i <= 5; i++){

???????

??????? for(int j = 1; j <= 5 - i; j++)

????????? System.out.print("");

???????

??????? for(int j = 1; j <= 5; j++)

????????? System.out.print("*");

???????

??????? System.out.println();

???? }

???? */

????

???? //百錢百雞

???? for(int i = 1; i < 33; i++){ //表示公雞的個數(shù)

??????? for(int j = 1; j < 50; j++){//表示母雞的個數(shù)

????????? //計算小雞的個數(shù)

????????? int k = 100 - i - j;

????????? if(k % 3 == 0 && i * 3 + j * 2+ k / 3 == 100){

???????????? System.out.println("公雞" + i);

???????????? System.out.println("母雞" + j);

???????????? System.out.println("小雞" + k);

???????????? System.out.println("==================");

????????? }

??????? }?

???? }???

?? }

}

8

importjava.util.Scanner;

public class LoopDemo2{

??

?? public static void main(String[] args){

????

???? Scanner s = new Scanner(System.in);

???? int n = s.nextInt();

????

???? //標(biāo)記這個數(shù)字是否是一個質(zhì)數(shù)

???? //規(guī)定如果為true表示是一個質(zhì)數(shù)馆纳,如果為false表示不是一個質(zhì)數(shù)

???? boolean b = true;

????

???? //判斷一個數(shù)字是否是一個質(zhì)數(shù)

???? //從2開始逐個往后取余诗良,看是否還有別的因數(shù),如果沒有別的因數(shù)鲁驶,那么就是一個質(zhì)數(shù)鉴裹,反之就說明不是質(zhì)數(shù)

???? for(int i = 2; i < n; i++){

??????? //如果能夠取余,說明n除了1和本身以外還有別的因數(shù)钥弯,那么n就不是質(zhì)數(shù)

??????? if(n % i == 0){

????????? b = false;

????????? break;

??????? }

???????

???? }

????

???? if(b)

??????? System.out.println(n + "是一個質(zhì)數(shù)");

???? else

??????? System.out.println(n + "不是一個質(zhì)數(shù)");

????

?? }

??

}

9径荔、

public classLoopDemo {

?

?? public static void main(String[] args){

???? // *******

???? /*

???? for(int i = 1; i <= 7; i++){

??????? //不換行打印

??????? // ln -> line

??????? System.out.print("*");

???? }

???? System.out.println();

???? */

?

???? /*

??????? *******

??????? *******

??????? *******

??????? *******

???? */

???? //循環(huán)的嵌套

???? /*

???? for(int count = 1; count <= 5; count++){

??????? for(int i = 1; i <= 7; i++){

????????? System.out.print("*");

??????? }

??????? System.out.println();

???? }

???? */

?

???? /*

??????? *

??????? **

??????? ***

??????? ****

??????? *****

??????? ******

??????? 行數(shù):1 -> n

??????? 第i行*的個數(shù):1->i

???? */

???? /*

???? for(int i = 1; i <= 6; i++){

??????? for(int j = 1; j <= i; j++){

????????? System.out.print("*");

??????? }

??????? System.out.println();

???? }

???? */

???? /*

??????? ******

??????? *****

??????? ****

??????? ***

??????? **

??????? *

??????? 行數(shù):n -> 1

??????? 每一行的*的個數(shù):i -> 1

???? */

???? /*

???? for(int i = 6; i > 0; i--){

??????? for(int j = i; j > 0; j--){

????????? System.out.print("*");

??????? }

??????? System.out.println();

???? }

???? */

????

???? /*

??????? -----*

??????? ----**

??????? ---***

??????? --****

??????? -*****

??????? ******

??????? 行數(shù):1 -> n

??????? 空格的個數(shù):1 -> n-i

??????? *的個數(shù):1 -> i

???? */

???? /*

???? for(int i = 1; i <= 6; i++){

??????? //先打印空格

??????? for(int j = 1; j <= 6 - i; j++){

????????? System.out.print("");

??????? }

??????? //打印*

??????? for(int k = 1; k <= i; k++){

????????? System.out.print("*");

??????? }

??????? System.out.println();

???? }

???? */

????

???? /*

??????? ******

??????? ?*****

??????? ?****

??????? ??***

??????? ???**

????????? ?*

??????? 行數(shù):n -> 1

??????? 空格個數(shù):n-i -> 1

??????? *的個數(shù):i -> 1

???? */

???? for(int i = 6; i > 0; i--){

???????

??????? for(int j = 6 - i; j > 0; j--)

????????? System.out.print("");

???????

??????? for(int j = i; j > 0; j--)

????????? System.out.print("*");

???????

??????? System.out.println();

???????

10

importjava.util.Scanner;

public classIfElseIfExer {

??

?? public static void main(String[] args){

????

???? //輸入數(shù)字

???? Scanner s = new Scanner(System.in);

???? int n = s.nextInt();

????

???? //判斷這個數(shù)字是否合法

???? if(n < 1 || n > 7){

??????? System.out.println("星期不合法4圉W艽Α!");

???? } else if(n == 1){

??????? System.out.println("星期一");

???? } else if(n == 2){

??????? System.out.println("星期二");

???? } else if(n == 3){

??????? System.out.println("星期三");

???? } else if(n == 4){

??????? System.out.println("星期四");

???? } else if(n == 5){

??????? System.out.println("星期五");

???? } else if(n == 6){

??????? System.out.println("星期六");

???? } else {

??????? System.out.println("星期天");

11睛蛛、

public classForDemo {

?

?? public static void main(String[] args){

????

???? /*

???? for(int i = 1; i <= 10; i++){

??????? System.out.println("Hello");

???? }

???? */

????

???? //求1-50的和

???? int sum = 0;

???? // for()內(nèi)有3部分組成

???? //對于for循環(huán)而言鹦马,如果第二部分的控制條件沒有寫,那么默認為true玖院,這個時候就成了一個死循環(huán)

???? for(int i = 1; i <= 10; i++){

??????? sum += i;

???? }

???? // System.out.println(sum);

????

12菠红、

public classForDemo {

?

?? public static void main(String[] args){

????

???? /*

???? for(int i = 1; i <= 10; i++){

??????? System.out.println("Hello");

???? }

???? */

????

???? //求1-50的和

???? int sum = 0;

???? // for()內(nèi)有3部分組成

???? //對于for循環(huán)而言,如果第二部分的控制條件沒有寫难菌,那么默認為true试溯,這個時候就成了一個死循環(huán)

???? for(int i = 1; i <= 10; i++){

??????? sum += i;

???? }

???? // System.out.println(sum);

??

13

public classContinueDemo {

?

?? public static void main(String[] args){

??

???? /*

???? for(int i = 1; i < 5; i++){

???????

??????? if(i % 2 == 0)

????????? //表示這次循環(huán)直接跳過郊酒,執(zhí)行下一次的循環(huán)

????????? continue;

???????

??????? System.out.println(i);

???????

???? }

???? */

???? for(int i = 1; i < 5; i++){

???????

??????? for(int j = 1; j < 5; j++){

?????????

????????? if(j % 2 == 0)

???????????? continue;

?????????

????????? System.out.println(i + "," +j);

?????????

14遇绞、

public classBreakDemo {

?

?? public static void main(String[] args){

????

???? /*

???? for(int i = 1; i < 5; i++){

???????

??????? if(i % 2 == 0)

????????? //表示遇到了break之后,循環(huán)結(jié)構(gòu)就會結(jié)束

????????? break;

???????

??????? System.out.println(i);

???????

???? }

???? */

????

???? for(int i = 1; i < 5; i++){

???????

??????? for(int j = 1; j < 5; j++){

?????????

????????? if(j % 3 == 0)

???????????? //表示終止當(dāng)前的一層結(jié)構(gòu)

???????????? break;

?????????

????????? System.out.println(i + "," +j);

?????????

15燎窘、

public class ArrayDemo{

?? public static void main(String[] args){

????

???? byte[] arr = new byte[5];

???? // arr[2] = 10;

???? //最大下標(biāo)為4

???? // ArrayIndexOutOfBoundsException -數(shù)組下標(biāo)越界異常

???? // arr[5] = 7;

???? // System.out.println(arr[2]);

???? // boolean[] bs = new boolean[4];

???? // String[] arr = new String[7];

???? System.out.println(arr);

???? // System.out.println(arr[1]);

????

16摹闽、

?

p>

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市褐健,隨后出現(xiàn)的幾起案子付鹿,更是在濱河造成了極大的恐慌澜汤,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,997評論 6 502
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件舵匾,死亡現(xiàn)場離奇詭異俊抵,居然都是意外死亡,警方通過查閱死者的電腦和手機坐梯,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,603評論 3 392
  • 文/潘曉璐 我一進店門徽诲,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人吵血,你說我怎么就攤上這事谎替。” “怎么了蹋辅?”我有些...
    開封第一講書人閱讀 163,359評論 0 353
  • 文/不壞的土叔 我叫張陵钱贯,是天一觀的道長。 經(jīng)常有香客問我侦另,道長喷舀,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,309評論 1 292
  • 正文 為了忘掉前任淋肾,我火速辦了婚禮硫麻,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘樊卓。我一直安慰自己拿愧,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,346評論 6 390
  • 文/花漫 我一把揭開白布碌尔。 她就那樣靜靜地躺著浇辜,像睡著了一般。 火紅的嫁衣襯著肌膚如雪唾戚。 梳的紋絲不亂的頭發(fā)上柳洋,一...
    開封第一講書人閱讀 51,258評論 1 300
  • 那天,我揣著相機與錄音叹坦,去河邊找鬼熊镣。 笑死,一個胖子當(dāng)著我的面吹牛募书,可吹牛的內(nèi)容都是我干的绪囱。 我是一名探鬼主播,決...
    沈念sama閱讀 40,122評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼莹捡,長吁一口氣:“原來是場噩夢啊……” “哼鬼吵!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起篮赢,我...
    開封第一講書人閱讀 38,970評論 0 275
  • 序言:老撾萬榮一對情侶失蹤齿椅,失蹤者是張志新(化名)和其女友劉穎琉挖,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體涣脚,經(jīng)...
    沈念sama閱讀 45,403評論 1 313
  • 正文 獨居荒郊野嶺守林人離奇死亡粹排,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,596評論 3 334
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了涩澡。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 39,769評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡坠敷,死狀恐怖妙同,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情膝迎,我是刑警寧澤粥帚,帶...
    沈念sama閱讀 35,464評論 5 344
  • 正文 年R本政府宣布,位于F島的核電站限次,受9級特大地震影響芒涡,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜卖漫,卻給世界環(huán)境...
    茶點故事閱讀 41,075評論 3 327
  • 文/蒙蒙 一费尽、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧羊始,春花似錦旱幼、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,705評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至匀油,卻和暖如春缘缚,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背敌蚜。 一陣腳步聲響...
    開封第一講書人閱讀 32,848評論 1 269
  • 我被黑心中介騙來泰國打工桥滨, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人弛车。 一個月前我還...
    沈念sama閱讀 47,831評論 2 370
  • 正文 我出身青樓该园,卻偏偏與公主長得像,于是被迫代替她去往敵國和親帅韧。 傳聞我的和親對象是個殘疾皇子里初,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,678評論 2 354

推薦閱讀更多精彩內(nèi)容

  • 【程序1】 題目:古典問題:有一對兔子,從出生后第3個月起每個月都生一對兔子忽舟,小兔子長到第三個月后每個月又生一...
    阿里高級軟件架構(gòu)師閱讀 3,286評論 0 19
  • 【程序1】 題目:古典問題:有一對兔子双妨,從出生后第3個月起每個月都生一對兔子淮阐,小兔子長到第三個月后每個月又生一對兔...
    葉總韓閱讀 5,134評論 0 41
  • Java經(jīng)典問題算法大全 /*【程序1】 題目:古典問題:有一對兔子,從出生后第3個月起每個月都生一對兔子刁品,小兔子...
    趙宇_阿特奇閱讀 1,863評論 0 2
  • 【程序1】 題目:古典問題:有一對兔子泣特,從出生后第3個月起每個月都生一對兔子,小兔子長到第三個月后每個月又生一對兔...
    開心的鑼鼓閱讀 3,320評論 0 9
  • 昏暗的房間挑随,電腦屏幕透過來的光還有耳麥里傳來的音樂状您,一切都是剛剛好的模樣。 艾瑪還在餐館里做事兜挨,這是1990年的7...
    是陌陌啊閱讀 256評論 0 0