随笔分类 - Java学习
摘要:基本思路: 保证0~0有序,然后0~1有序,0~2有序,0~i有序的过程 因为0~0肯定是有序的 所以外循环从1开始 比较条件: 前面还有没有数据 && 前面索引的值 > 后面索引的值 时间复杂度最差情况是bigO(n2) 最好情况是bigO(n) public class InsertionSor
阅读全文
摘要:基本思路就是索引(0,1)比较,(1,2)比较,(2,3)比较依次进行比较,最后索引最大处的值必然为最大的值,外层循环每进行一轮比较就可以减少一次 比如第一轮是(0~n-1) 第二轮就是 (0~n-2) 时间复杂度也是bigO(n2) public class BubbleSort { public
阅读全文
摘要:public class SelectionSort { public static void selectionSort(int[] arr) { //边界判断 if (arr == null || arr.length < 2) { return; } //1.控制范围 i~n-1 for (i
阅读全文
摘要:Student类: public class Student { public void study(){ System.out.println("好好学习,天天向上"); } } View Code Teacher类: public class Teacher { public void teac
阅读全文
摘要:public class ReflectTest { public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Ar
阅读全文
摘要:public class ReflectDemo04 { public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, Invo
阅读全文
摘要:Method[] getMethods() 返回包含一个数组 方法对象反射由此表示的类或接口的所有公共方法类对象,包括那些由类或接口和那些从超类和超接口继承的声明。 public class ReflectDemo03 { public static void main(String[] args)
阅读全文
摘要:public class ReflectDemo02 { public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, Invo
阅读全文
摘要:Field[] getFields() 返回包含一个数组Field对象反射由此表示的类或接口的所有可访问的公共字段类对象。 public class ReflectDemo01 { public static void main(String[] args) throws ClassNotFound
阅读全文
摘要:public class ReflectDemo03 { public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, Invo
阅读全文
摘要:Student类: package com.reflect_02; public class Student { private String name; int age; public String address; //构造方法:1个私有,1个默认,2个公开 public Student() {
阅读全文
摘要:public class ReflectDemo02 { public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, Invo
阅读全文
摘要:public class ReflectDemo { public static void main(String[] args) throws ClassNotFoundException { //1.使用类的class属性来获取该类对应的Class对象。 Class<Student> c1 =
阅读全文
摘要:public class CollectorDemo { public static void main(String[] args) { List<String> list = new ArrayList<>(); list.add("林青霞"); list.add("张曼玉"); list.ad
阅读全文
摘要:public class StreamTest { public static void main(String[] args) { //创建集合存储元素 ArrayList<String> manArray = new ArrayList<>(); manArray.add("刘德华"); man
阅读全文
摘要:public class StreamDemo06 { public static void main(String[] args) { ArrayList<String> list = new ArrayList<>(); list.add("赵敏"); list.add("张无忌"); list
阅读全文
摘要:public class StreamDemo05 { public static void main(String[] args) { //创建一个集合,存储多个字符串元素 ArrayList<String> list = new ArrayList<>(); list.add("10"); li
阅读全文
摘要:public class StreamDemo04 { public static void main(String[] args) { //创建一个集合添加元素 ArrayList<String> list = new ArrayList<>(); list.add("linqingxia");
阅读全文
摘要:public class StreamDemo03 { public static void main(String[] args) { //创建一个集合 ArrayList<String> list = new ArrayList<>(); list.add("赵敏"); list.add("张无
阅读全文
摘要:public class StreamDemo02 { public static void main(String[] args) { //创建一个集合 ArrayList<String> list = new ArrayList<>(); list.add("赵敏"); list.add("张无
阅读全文