2021年3月2日
摘要: 稀疏数组 import java.util.Arrays;​public class Demo4 { public static void main(String[] args) { //稀疏数组 int[][] arrays={{3,10,6},{0,2,1},{0,6,1},{1,0,1},{1 阅读全文
posted @ 2021-03-02 22:07 要给小八赚罐头钱 阅读(84) 评论(0) 推荐(0)
摘要: import java.util.Arrays; public class Demo3 { public static void main(String[] args) { int[] nums={8,4,53,23,2,6,3}; for (int i = 0; i < nums.length; 阅读全文
posted @ 2021-03-02 20:17 要给小八赚罐头钱 阅读(11) 评论(0) 推荐(0)
摘要: # 可变参数 一个方法中只能指定一个可变参数,且必须是方法的最后一个参数。 ```javapublic static void test(int... i){}``` 阅读全文
posted @ 2021-03-02 19:36 要给小八赚罐头钱 阅读(21) 评论(0) 推荐(0)
摘要: # 命令行传参 命令行执行时需在src目录下 ```javapublic static void main(String args[]){ for(int i=0;i<args.length;i++){ System.out.println("args["+i+"];"+args[i]); }}`` 阅读全文
posted @ 2021-03-02 19:34 要给小八赚罐头钱 阅读(37) 评论(0) 推荐(0)
摘要: # 打印三角形 ```javapublic class Demo1 { public static void main(String[] args) { for (int i = 5; i > 0; i--) { for (int j = 0; j < i; j++) { System.out.pr 阅读全文
posted @ 2021-03-02 11:20 要给小八赚罐头钱 阅读(8) 评论(0) 推荐(0)
摘要: # 退出循环 - break用于强制退出循环 - continue用于终止某次循环 - goto 阅读全文
posted @ 2021-03-02 10:54 要给小八赚罐头钱 阅读(32) 评论(0) 推荐(0)
摘要: # equals判断字符串是否相等 阅读全文
posted @ 2021-03-02 10:52 要给小八赚罐头钱 阅读(20) 评论(0) 推荐(0)
摘要: # switch switch语句中的变量类型可以是byte/short/int/char/string。 ```javaswitch(变量){ case 值: break; default: }``` 阅读全文
posted @ 2021-03-02 10:51 要给小八赚罐头钱 阅读(24) 评论(0) 推荐(0)
摘要: Scanner类 用于获取用户的输入 Scanner s = new Scanner(System.in); scanner.hasNext(); scanner.hasNextLine(); scanner.next();; 一定要读取到有效字符后才可以结束输入。 对输入有效字符之前遇到的空白,n 阅读全文
posted @ 2021-03-02 10:22 要给小八赚罐头钱 阅读(13) 评论(0) 推荐(0)