类型通配符一般使用?代替具体的类型参数,例如List<?>可以代表List<Integer>,也能代表List<String>,等所有list<具体类型的>父类
举个栗子:
List<String> friend1 = new ArrayList<String>();
List<Integer> friend2 = new ArrayList<Integer>();
friend1.add("李燕茹");
friend2.add(1024);
getFirstData(friend1);
getFirstData(friend2);
public static void getFirstData(List<?> data) {
System.out.println(data.get(0));
} public class test { public static void main(String[] args) { &...
java一个类可以有多个构造方法,根据传参类型和个数来匹配执行哪个构造方法。public class Member { public Member(){  ...
(1).final 修饰符通常和 static 修饰符一起使用来创建类常量。(2).父类中的 final 方法可以被子类继承,但是不能被子类重写,声明 final 方法的主要目的是防止该方法的内容被修改。public class Member {  ...
在java中字符串属于对象,刚开始我就疑惑为什么int char等类型都是小写,结果String是大写,java太反人类,后来才知道String是对象。(1).java创建字符串String text = "net"; String tex...
假如有个字符串为"fatcatfatcatfat",正则为“cat”当调用appendReplacement(sb, "dog")时appendReplacement方法都会把匹配到的内容替换为dog,并把匹配到字符串的前面几个字符串+dog送给sb里,所以第...
java FileInputStream(12.1)FileInputStream将文件读入作为流来处理,有两种实例化方式// 方式1 FileInputStream fis = new FileInputStream("./learn.t...