摘要:
public class Demo04 { public static void main(String[] args) { //实际参数和形式参数的类型要对应 int add = Demo04.add(1,2); System.out.println(add); } public static i 阅读全文
posted @ 2022-10-12 16:56
江江要努力
阅读(15)
评论(0)
推荐(0)
摘要:
public class Demo03 { public static void main(String[] args) { int a = 1; System.out.println(a);//1 Demo03.change(a); System.out.println(a);//1 } //返回 阅读全文
posted @ 2022-10-12 16:55
江江要努力
阅读(16)
评论(0)
推荐(0)
摘要:
import java.io.IOException;//Demo01类public class Demo01 { //main方法 public static void main(String[] args) { } /* 修饰符 返回值类型 方法名(...){ //方法体 return 返回值; 阅读全文
posted @ 2022-10-12 16:54
江江要努力
阅读(17)
评论(0)
推荐(0)
摘要:
public class Dome02 { public static void main(String[] args) { //逻辑运算符 boolean a = true; boolean b = false; System.out.println("a && b:"+(a&&b));//逻辑与 阅读全文
posted @ 2022-10-12 16:48
江江要努力
阅读(31)
评论(0)
推荐(0)
摘要:
public class Demo01 { public static void main(String[] args) { //自增++ 自减-- 一元运算符 int f = 3; int g = f++;//执行完这行代码后,先给g赋值,再自增 //f = f + 1; System.out.p 阅读全文
posted @ 2022-10-12 16:47
江江要努力
阅读(34)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo03 { public static void main(String[] args) { //输入多个数字,并求其总和与平均数,没输入一个数字用回车确认,通过输入非数字来结束输入并输出执行结果 Scanner sc 阅读全文
posted @ 2022-10-12 16:46
江江要努力
阅读(140)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo02 { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //从键盘接收数据 int i = 0; 阅读全文
posted @ 2022-10-12 16:45
江江要努力
阅读(33)
评论(0)
推荐(0)
摘要:
import java.util.Scanner;public class Demo01 { public static void main(String[] args) { //创建一个扫描器对象,用于接收键盘数据 Scanner scanner = new Scanner(System.in); 阅读全文
posted @ 2022-10-12 16:44
江江要努力
阅读(25)
评论(0)
推荐(0)
摘要:
public class Demo08 { public static void main(String[] args) { //打印三角形 for (int i = 1; i <= 5; i++) { for(int j = 5;j >= i;j--){ System.out.print(" ") 阅读全文
posted @ 2022-10-12 16:42
江江要努力
阅读(15)
评论(0)
推荐(0)
摘要:
public class Demo07 { public static void main(String[] args) { //打印101-150之间的所有质数 //质数是指在大于1的自然数中,除了1和它本身以外不再有其他因数的自然数 int count = 0; //不建议使用!!!! oute 阅读全文
posted @ 2022-10-12 16:42
江江要努力
阅读(23)
评论(0)
推荐(0)
摘要:
public class Demo06 { public static void main(String[] args) { //break语句用于强行退出循环,不执行循环中剩余的语句。(break语句也在swith语句中使用) //continue语句用在循环语句体中,用于终止某次循环过程,即跳过 阅读全文
posted @ 2022-10-12 16:41
江江要努力
阅读(25)
评论(0)
推荐(0)
摘要:
public class Demo05 { public static void main(String[] args) { /*计算0-100之间的奇数和偶数的和 int oddSum = 0; int evenSum = 0; for (int i = 0; i <= 100; i++) { i 阅读全文
posted @ 2022-10-12 16:40
江江要努力
阅读(31)
评论(0)
推荐(0)
摘要:
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)
浙公网安备 33010602011771号