摘要: public class ArgsDemo { public static void main(String[] args) { System.out.println(sum(10, 20)); System.out.println(sum(10, 20, 30)); System.out.prin 阅读全文
posted @ 2020-04-09 17:38 硬盘红了 阅读(113) 评论(0) 推荐(0) 编辑
摘要: public class GenericDemo { public static void main(String[] args) { //类型通配符:<?> List<?> list1 = new ArrayList<Object>(); List<?> list2 = new ArrayList 阅读全文
posted @ 2020-04-09 17:25 硬盘红了 阅读(370) 评论(0) 推荐(0) 编辑
摘要: 用最原始的调用方法来输出不同数据类型的元素时,需要创建不同数据类型参数的重载方法,例如: //普通方法 public class Generic { public void show(String s){ System.out.println(s); } public void show(Integ 阅读全文
posted @ 2020-04-09 16:24 硬盘红了 阅读(150) 评论(0) 推荐(0) 编辑
摘要: public class SetDemo { public static void main(String[] args) { //创建集合对象,分别使用两种子类 //Set<Integer> set = new HashSet<Integer>(); //Set<Integer> set = ne 阅读全文
posted @ 2020-04-09 14:30 硬盘红了 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 首先根据思路编写代码,然后根据要求分析排序的主要条件和次要条件(分析思路在文末),在学生类中有三个成员变量,姓名(name),语文成绩(chinese),数学成绩(math),要求按照总分排序,在本需求中仅需要两科成绩,如果需要多门成绩时多次调用get方法就比较麻烦,可以在学生类中提供一个公开的获取 阅读全文
posted @ 2020-04-09 11:38 硬盘红了 阅读(288) 评论(0) 推荐(0) 编辑
摘要: public class TreeSetDemo { public static void main(String[] args) { //创建集合对象 TreeSet<Student> treeSet = new TreeSet<Student>(new Comparator<Student>() 阅读全文
posted @ 2020-04-09 10:42 硬盘红了 阅读(631) 评论(0) 推荐(0) 编辑