随笔分类 -  java

摘要:文件 1. 两种路径 //1,绝对路径 从盘符开始的路径 File file1 = new File("D:\\fil\\a.txt"); //2,相对路径 相对于工程的路径 // ../返回上一层目录 File file2 = new File("./fil/a.txt "); 2. File常用 阅读全文
posted @ 2023-03-17 22:29 VIoleng 阅读(20) 评论(0) 推荐(0)
摘要:1. 泛型 JDK5开始出现了泛型的使用 泛型符号 可以应用在 类,接口,方法 的声明处,起到一个占位符的作用,先占个位置 ,给引用类型占个位置; 泛型符号 名称和个数无要求 ; T type E element K key V value 泛型符号出现在类的声明处和接口的声明处 都可以当成已知类型 阅读全文
posted @ 2023-03-16 22:03 VIoleng 阅读(137) 评论(0) 推荐(0)
摘要:Map接口 成对的对象(两个对象 ) 才能作为一个 集合元素对象,一对才算一个,Key(主键):Value(值) Map的Key对象是不可重复的 key对象(是具有唯一性的 能唯一地代表某个value对象的对象 才能作为主键)例如 单车的id 人的id 学生的id Map的实现类 HashMap 哈 阅读全文
posted @ 2023-03-15 22:00 VIoleng 阅读(33) 评论(0) 推荐(0)
摘要:List 的遍历 ArrayList<String> list = new ArrayList<>(); 1 forEach循环遍历 list.forEach(new Consumer<String>() { @Override public void accept(String s) { Syst 阅读全文
posted @ 2023-03-14 22:22 VIoleng 阅读(19) 评论(0) 推荐(0)
摘要:集合 ArrayList 优点:ArrayList底层用的是Object数组,因为数组内存空间是连续的 所以查询性能很高 时间复杂度 O(1); 缺点:ArrayList底层用的是Object数组;所以在进行删除元素和指定位置新增的时候 因为涉及到元素移动 所以性能较低 O(n) List list 阅读全文
posted @ 2023-03-13 22:02 VIoleng 阅读(21) 评论(0) 推荐(0)
摘要:反射 1. 获取类对象的三种方法 public static void method2() throws ClassNotFoundException { //获取类对象方法 1 Class<Monkey> c1 = Monkey.class; //获取类对象方法 2 Monkey class2 = 阅读全文
posted @ 2023-03-10 22:34 VIoleng 阅读(17) 评论(0) 推荐(0)
摘要:this this(id,name);//调用另一个方法只能放在第一行 this id = id; this name = name; public Student(int id, String name, char gender) { this.id = id; this.name = name; 阅读全文
posted @ 2023-03-10 22:33 VIoleng 阅读(17) 评论(0) 推荐(0)
摘要:lombok 注解开发: @解释名称 只需要在类上,方法,属性,形参 加上一个注解 就配置完成了 效率很快 this this(id,name);//调用另一个方法只能放在第一行this id = id;this name = name;​​public Student(int id, String 阅读全文
posted @ 2023-03-04 15:06 VIoleng 阅读(21) 评论(0) 推荐(0)
摘要:default switch(num): case 1:语句;break; case 2:语句;break; case 3:语句;break; default:语句;break; Random 随机数 Random r = new Random();r.nextInt(9000)+1000;//4位 阅读全文
posted @ 2023-02-25 21:07 VIoleng 阅读(17) 评论(0) 推荐(0)