摘要: public class ArrayDemo02 { public static void main(String[] args) { //静态初始化: 创建+赋值 int[] a = {1,2,3,4,5,6,7,8}; System.out.println(a[0]); //动态初始化:包含默认 阅读全文
posted @ 2023-10-28 20:45 版本答案 阅读(1) 评论(0) 推荐(0) 编辑
摘要: public class ArrayDemo01 { public static void main(String[] args) { //变量类型 变量的名字 = 变量的值; //数组类型 int[] nums;//1、定义(声明一个数组) nums = new int[10];//2、这里面可以 阅读全文
posted @ 2023-10-28 20:44 版本答案 阅读(6) 评论(0) 推荐(0) 编辑
摘要: public class Demo07 { public static void main(String[] args) { //用scanner创建一个扫描器对象,用于接收键盘数据 Scanner scanner = new Scanner(System.in);//System.in是输入的意思 阅读全文
posted @ 2023-10-28 20:43 版本答案 阅读(17) 评论(0) 推荐(0) 编辑
摘要: public class Demo06 { //递归思想 public static void main(String[] args) { System.out.println(f(5)); } //1! 1 //5! 5*4*3*2*1 public static int f(int n){ if 阅读全文
posted @ 2023-10-28 20:43 版本答案 阅读(4) 评论(0) 推荐(0) 编辑
摘要: public class Demo03 { public static void main(String[] args) { //args.length 数组长度 for (int i = 0; i < args.length; i++){ System.out.println("args[" + 阅读全文
posted @ 2023-10-28 20:41 版本答案 阅读(42) 评论(0) 推荐(0) 编辑
摘要: public class Demo02 { public static void main(String[] args) { int max = max(10, 30 ,20); System.out.println(max); } /* 方法的重载的规则: 1、方法名称必须相同!!! 2、参数列表 阅读全文
posted @ 2023-10-28 20:41 版本答案 阅读(3) 评论(0) 推荐(0) 编辑
摘要: public class Demo01 {// mian方法 public static void main(String[] args) { //实际参数:实际调用传递给他的参数 int sum = add(1,2); System.out.println(sum);// test(); } // 阅读全文
posted @ 2023-10-28 20:38 版本答案 阅读(1) 评论(0) 推荐(0) 编辑
摘要: public class BreakDemo { public static void main(String[] args) { int i = 0; while (i<100){ i++; System.out.println(i); if (i==30){ break; } } System. 阅读全文
posted @ 2023-10-28 20:37 版本答案 阅读(2) 评论(0) 推荐(0) 编辑
摘要: public class ForDemo05 { public static void main(String[] args) { int[] numbers = {10,20,30,40,50};//定义了一个数组 for (int i = 0;i<5;i++){ System.out.print 阅读全文
posted @ 2023-10-28 20:34 版本答案 阅读(1) 评论(0) 推荐(0) 编辑
摘要: public class TestDemo { public static void main(String[] args) { //打印三角形 for (int i = 1;i <= 5; i++){ for (int j = 5;j>=i;j--){ System.out.print(" "); 阅读全文
posted @ 2023-10-28 20:33 版本答案 阅读(3) 评论(0) 推荐(0) 编辑