摘要:
public class Demo03 { public static void main(String[] args) { //少部分情况需要一直执行,比如服务器的请求响应监听等 //循环条件一直为true就会造成死循环(无限循环)应避免这个情况出现 /*输出1-100 int i = 0; wh 阅读全文
posted @ 2022-10-12 16:38
江江要努力
阅读(24)
评论(0)
推荐(0)
摘要:
public class Demo04 { public static void main(String[] args) { //for循环语句是综测迭代的一种通用结构,是最有效最灵活的循环结构 int a = 1;//初始化条件 while(a<=100){//条件判断 System.out.pr 阅读全文
posted @ 2022-10-12 16:37
江江要努力
阅读(93)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo02 { public static void main(String[] args) { //case 穿透(故每个语句后都要加break) switch 匹配一个具体的值 /*JDK7新特性,表达式结果可以是字符 阅读全文
posted @ 2022-10-12 16:36
江江要努力
阅读(12)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo01 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println(" 阅读全文
posted @ 2022-10-12 16:35
江江要努力
阅读(28)
评论(0)
推荐(0)
摘要:
public class Demo05 { //递归思想(调用自身),数量大的话,不用这个 public static void main(String[] args) { System.out.println(f(5)); } public static int f(int n){ if (n== 阅读全文
posted @ 2022-10-12 16:33
江江要努力
阅读(22)
评论(0)
推荐(0)
摘要:
public class Demo04 { //在方法声明中,在指定参数类型后加一个省略号... //一个方法只能指定一个可变参数,它必须是方法的最后一个参数,任何普通的参数必须在它之前声明 public static void main(String[] args) { //调用可变参数的方法 p 阅读全文
posted @ 2022-10-12 16:33
江江要努力
阅读(23)
评论(0)
推荐(0)
摘要:
public class Demo02 { public static void main(String[] args) { double max = max(10,30); System.out.println(max); } //比大小int public static int max(int 阅读全文
posted @ 2022-10-12 16:26
江江要努力
阅读(23)
评论(0)
推荐(0)
摘要:
public class Demo01 { //main方法 public static void main(String[] args) { //实际参数:实际调用传递给它的参数 int sum = add(1, 2); System.out.println(sum); test(); //mai 阅读全文
posted @ 2022-10-12 16:24
江江要努力
阅读(31)
评论(0)
推荐(0)
摘要:
import java.util.Arrays;public class Demo07 { public static void main(String[] args) { int[] a = {1,5,8,3,22,13}; int[] sort = sort(a);//调用完自己写的排序方法后, 阅读全文
posted @ 2022-10-12 16:14
江江要努力
阅读(37)
评论(0)
推荐(0)
摘要:
public class Demo08 { public static void main(String[] args) { //创建一个二维数组5*5 int[][] array1 = new int[5][5]; array1[1][2] = 1; array1[2][2] = 3; //输出原 阅读全文
posted @ 2022-10-12 16:14
江江要努力
阅读(19)
评论(0)
推荐(0)
浙公网安备 33010602011771号