1、java中的继承只可以继承一个父类,可以通过实现接口的方法来弥补这一缺点。但是实现一个借口就必须需要实现接口里面的方法,接口中方法不能有方法体,同时方法的访问修饰符不能是 private 和 protected。
2、抽象类中的方法一定要用abstract来修饰
3、对于使用Calendar来获取到的时间,其中Calendar.month中0代表的是一月份,所以如果需要得到正常的数值,则需要加一。
4、不要直接在class中写代码,应该在方法中补全自己的代码。
5.对于java中的文件操作,如果不想一次读取一行,那么应该怎么操作呢,可以一次全部把所需要的数据全部读出,保存到一个byte数组中,然后使用String的构造方法把数组转换成一个字符串。实例如下:
package read;
/**
* Created with IntelliJ IDEA.
* User: shuaiy
* Date: 16-9-25
* Time: 下午83:28
* To change this template use File | Settings | File Templates.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class ReadFile {
public static void main(String args[]) throws IOException {
File file = new File("E:\\json\\readFile\\src\\read", "12.txt");
Long filelength = file.length();
byte[] content = new byte[filelength.intValue()];
FileInputStream in = null;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException e1) {
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
try {
in.read(content);
in.close();
} catch (IOException e1) {
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
System.out.println(new String(content));
}
}