1. stringBuider 声明一般给个值 list同 无论是sb还是集合类,扩容都是消耗性能的
stringbuffer尽量不要用 性能差
2. try catch try(jdk1.7之后在这里能写代码) 需要手动关闭的流,像FileInputStream ,Scanner 写在括号里,跳出try catch的时候,就会自动关闭流,不用在finally中手动关闭。
3.打印日志是个好习惯
4.能复用的类 写成final static 。在方法外。
5.异常自己自定义类
6.声明集合尽量自己给定长度;
List<V> list = new ArrayList<>(length);
持续更新