func OpenFile(name string, flag int, perm FileMode) (*File, error)
f, err := os.OpenFile("notes.txt", os.O_RDWR|os.O_CREATE|O_TRUNC, 0755)
Run Code Online (Sandbox Code Playgroud)
“O_TRUNC”是否在写入前清空整个文件?“截断”是什么意思?
另外,该函数ioutil.WriteFile()在写入之前是否清空了整个文件?
我不明白为什么equals()在我的代码中返回“false”而不是“true”?
class Location {
private int x, y;
public Location(int x, int y) {
this.x = x;
this.y = y;
}
}
public class App {
public static void main(String[] args) {
Location a = new Location(1, 2); //
Location b = new Location(1, 2); // same values
System.out.println(a.equals(b)); // result : "false"
}
}
Run Code Online (Sandbox Code Playgroud)
如何比较两个对象的值?