摘要: 1. 下标越界异常 2. 空指针异常 public class TestException { public static void main(String[] args) { // 数组下标越界异常:java.lang.ArrayIndexOutOfBoundsException: 10 int[ 阅读全文
posted @ 2020-03-11 09:38 林淼零 阅读(142) 评论(0) 推荐(0)
摘要: public class TestArray2 { public static void main(String[] args) { // 二维数组的初始化 String[][] names; int[][] scores = new int[][] { { 1, 2 }, { 1, 34, 5 } 阅读全文
posted @ 2020-03-11 01:10 林淼零 阅读(554) 评论(0) 推荐(0)
摘要: 从键盘输入的学生成绩,找出最高分, 并输出学生成绩等级 成绩 >=最高分-10 等级 A 成绩 >=最高分-20 等级 B 成绩 >=最高分-30 等级 C 其余 等级 D import java.util.Scanner; public class TestScore { public stati 阅读全文
posted @ 2020-03-11 00:36 林淼零 阅读(172) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2020-03-10 18:27 林淼零 阅读(132) 评论(0) 推荐(0)
摘要: 基于基本数据类型的变量创建的数组: byte short int long double float char boolean 对于基本数据类型为: byte short int long 初始化为 0 对于基本数据类型为: double float 默认的为 0.0 boolean 对于基本数据类 阅读全文
posted @ 2020-03-10 17:39 林淼零 阅读(1049) 评论(0) 推荐(0)
摘要: public class TestArray { public static void main(String[] args) { int i; i = 12; boolean b = true; // 定义一个数组;数组的声明 String[] names; int scores[]; // 初始 阅读全文
posted @ 2020-03-10 11:58 林淼零 阅读(91) 评论(0) 推荐(0)
摘要: 完数:一个数等于它的因子之和。 如 6=1+2+3 因子:除去这个数本身的正的约数 求1000内所有完数: public class TestWanShu { public static void main(String[] args) { int fa = 0; for (int i = 1; i 阅读全文
posted @ 2020-03-08 23:56 林淼零 阅读(515) 评论(0) 推荐(0)
摘要: break:使用在switch-case中或者循环体中如果使用在循环体中,表示:结束当前循环 continue: 使用在循环结构中 ,表示结束"当次"循环 了解break和continue标签的使用 注意:在break和continue语句后面不能添加其他语句,因为永远不能被执行。 public c 阅读全文
posted @ 2020-03-08 23:20 林淼零 阅读(112) 评论(0) 推荐(0)
摘要: 乘法表: /* 1*1=1 2*1=2 2*2=4 ... 9*1=9 . . . 9*9=81 * */ public class TestJiuJiu { public static void main(String[] args) { for (int i = 1; i <= 9; i++) 阅读全文
posted @ 2020-03-08 23:03 林淼零 阅读(390) 评论(0) 推荐(0)
摘要: 嵌套循环:循环中还可以声明循环。相当于内层循环的整体充当外层循环的循环体 public class TestForFor { public static void main(String[] args) { for (int i = 0; i < 4; i++) {// 外层循环控制行数 for ( 阅读全文
posted @ 2020-03-08 17:26 林淼零 阅读(398) 评论(0) 推荐(0)