123jgh

导航

 

2022年10月12日

摘要: 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)