随笔分类 -  JAVASE

记录自己在学习JAVA基础部分遇到的一些问题和处理方法。
摘要:int[] arr = {33, 55, 22, 11, 66, 88};int max = arr[0];for (int i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; }}System.out.println(ma 阅读全文
posted @ 2022-01-14 10:28 大灰狼21 阅读(39) 评论(0) 推荐(0)
摘要:存储多个相同类型。 int[] arr(推荐使用) int arr[] 初始化:分配空间、赋值。 动态初始化:只指定长度、系统分配初始值。 int[] arr=new int[3]; 静态初始化:指定元素初始值,由系统决定数组长度。 int[] arr=new int[]{1,2,3}; int[] 阅读全文
posted @ 2022-01-14 10:25 大灰狼21 阅读(41) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2022-01-13 18:56 大灰狼21 阅读(76) 评论(0) 推荐(0)
摘要:psvm+回车:快速生产main()方法 sout+回车:快速生成输出语句 ctrl+alt+space:内容提示、代码补全 选中代码+ctrl+/:单行注释 选中代码+ctrl+shift+/:多行注释 ctrl+alt+l:格式化 阅读全文
posted @ 2022-01-13 18:45 大灰狼21 阅读(47) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2022-01-13 17:41 大灰狼21 阅读(202) 评论(0) 推荐(0)
摘要:.java文件存放位置:D:\IdeaProjects\JavaSe_Code\idea_test\src\com .class文件存放位置:D:\IdeaProjects\JavaSe_Code\out\production\idea_test\com\itheima 在idea里输出栏的最后 阅读全文
posted @ 2022-01-13 17:40 大灰狼21 阅读(3317) 评论(0) 推荐(0)
摘要:Random r=new Random(); int number=r.nextInt(100)+1; while(true){ Scanner sc=new Scanner(System.in); System.out.println("请输入你猜的数字:"); int guessNumber=s 阅读全文
posted @ 2022-01-12 14:14 大灰狼21 阅读(47) 评论(0) 推荐(0)
摘要:import java.util.Scanner; Scanner sc=new Scanner(System.in); int i=sc.nextInt(); 阅读全文
posted @ 2022-01-12 14:03 大灰狼21 阅读(30) 评论(0) 推荐(0)
摘要://10个人有放回抽取0-9中10个数 import java.util.Random; Random r=new Random(); for(int i=1;i<=10;i++){ int number=r.nextInt(10); //取值范围[0,10) //左闭右开区间 System.out 阅读全文
posted @ 2022-01-12 14:01 大灰狼21 阅读(18) 评论(0) 推荐(0)
摘要:for(int hour=0;hour<24;hour++){ for(int minute=0;minute<60;minute++){ System.out.println(hour+"时"+minute+"分"); } System.out.println(" "); } 阅读全文
posted @ 2022-01-12 13:51 大灰狼21 阅读(33) 评论(0) 推荐(0)
摘要:语句:顺序语句 分支语句if、switch 循环语句for、while、do...while 阅读全文
posted @ 2022-01-12 13:50 大灰狼21 阅读(182) 评论(0) 推荐(0)
摘要:continue:跳过某次,继续下次 break:终止循环体,结束循环 阅读全文
posted @ 2022-01-12 13:34 大灰狼21 阅读(39) 评论(0) 推荐(0)
摘要:while适合不知道循环次书时用 for适合知道循环次数时用 do while不管对不对先执行一次 whiel和for先判断再执行 for循环的i如果不在循环外接收无法使用 while循环的i由于在循环外先初始化了可以使用 死循环 for(;;){ } while(true){ //三种死循环里最常 阅读全文
posted @ 2022-01-12 13:03 大灰狼21 阅读(104) 评论(0) 推荐(0)
摘要:371 个位数:371%10=1 百位数:371/100=3 十位数:371/10=37 37%10=7 推广到任意数: 123456789要得到5 先把5移动到个位 再取余 于是371 取各位实际上完整的是: 个位371/1%10=1 十位371/10%10=7 百位371/100%10=3 阅读全文
posted @ 2022-01-12 13:00 大灰狼21 阅读(1022) 评论(0) 推荐(0)
摘要:switch(表达式){ case 值1: 语句1; break; case 值2: 语句2; break; ... default: 语句n+1; [break;]//表示break可不写 } 表达式:byte、short、int、char JDK5后可以是枚举 JDK7后可以是String ca 阅读全文
posted @ 2022-01-12 12:46 大灰狼21 阅读(119) 评论(0) 推荐(0)
摘要:先判断数据是否符合规定,再按常规来,比方说,分数只能在0-100.先判断不在0一下||100以上 if(score>100||score<0){ //错误数据 }else if(score==100){ //满分 }else if(score>=90&&score<100){ //优秀 }else 阅读全文
posted @ 2022-01-11 19:32 大灰狼21 阅读(61) 评论(0) 推荐(0)
摘要:if(number%2==0){ //偶数 }else{ //奇数 } 阅读全文
posted @ 2022-01-11 19:23 大灰狼21 阅读(53) 评论(0) 推荐(0)
摘要:int i=10; int j=20; System.out.println((i++>100)&(j++>100));//false&false System.out.println(i); System.out.println(j); 输出结果 false 11 21 System.out.pr 阅读全文
posted @ 2022-01-11 19:16 大灰狼21 阅读(36) 评论(0) 推荐(0)
摘要:&逻辑与 只有true&true,输出结果才是true,其他都是false |逻辑或 只有false|false,输出结果才是false,其他都是true ^逻辑异或 false^false,true^true输出结果是fasle false^true,true^false输出结果是true 通俗的 阅读全文
posted @ 2022-01-11 19:07 大灰狼21 阅读(48) 评论(0) 推荐(0)
摘要:注意==和=的区别 int i=10; int j=20; System.out.println(i==j); 输出结果是false System.out.println(i=j); 输出结果是20 即把j的值赋给了i,并输出i现在的值。 阅读全文
posted @ 2022-01-11 18:48 大灰狼21 阅读(30) 评论(0) 推荐(0)