函数式接口
接口中只有一个抽象方法
匿名对象,只实例化不赋值给变量
匿名内部类,继承同时实例化
String s = new String(“abc”);创建了两个对象,一个是常量池中“abc” 一个是字符串对象
静态变量,在静态区
final static int //常量
局部代码块(局部变量的位置)
构造代码块(构造函数)
静态代码块 static{}
顺序:静态->构造->局部
pojo内一般包装类
局部变量一般基本数据类型
包装类除了Double和Float都会缓存一定范围数据
包装类和基本数据类型==
Integer a = 1;
Integer b = 1;
a==b;//true
Integer a = 128;
Integer b = 128;
a==b;//false
int a = 128;
int b = 128;
a==b;//true
Integer a = new Integer(1);
Integer b = new Integer(1);
a==b;//false
Integer a = new Integer(1);
int b = 1;
a==b;//true 隐式转换
接口
默认方法defaut,可以被继承重写
接口中的静态方法只能通过接口调用
接口中私有方法,只能在接口中调用,提供给接口中的默认方法和静态方法使用
集合
集合中必须存引用数据类型
Collection接口有两个子接口List、Set
List:ArrayList,LinkedList 有序,重复
Set:HashSet,TreeSet 无序,不重复
ArrayList实际上是一个长度可变的数组
数组:查询快,增删慢
链表:查询慢,增删快
泛型
把运行时错误提前到编译时
泛型的上限和下限
<? extends Person> 限定Person类的子类
<? super Student> 限定Student类的父类
IO流
file.getAbsolutePath()
file.getName()
file.getPath()
file.length()
f.createNewFile() //创建文件
f.delete() //删除文件
f.exist() //文件存在
f.isFile() //是否是文件
f.list() //f下所有文件和文件夹的名字
f.listFiles() //f下所有文件和文件夹的文件对象
字节输入/输出
FileInputStream FileOutputStream
bytes[] bys = new bytes[1024];
int len = fis.read(bys) fos.write(bys)
字符输出/输出
FileReader FileWriter
char[] buf= new char[10];
int len = fr.read(buf) fw.write(buf,0,len)
字节缓冲
BufferedInputStream BufferedOutpuStream
字符缓冲
BufferedWriter BufferedReader
bw.write() bw.newLine br.readLine()
序列化
被序列化的类必须实现serializable接口
private **transient **Integer age; 表示不被序列化
properties集合与io流交互
Properties pro = new Properties();
pro.setProperty(“zhangsan”,“23”);
FileOutputStream out = new FileOutStream(“template/pro.properties”);
pro.store(out,“save date”);//保存数据
out.close;
读取
Properties pro = new Properties();
FileInputStream input = new FileInputStream(“template/pro.properties”);
pro.load(input);
System.out.println(pro);