我从Properties.contains()
...得到意外的输出
这是我的代码...
File file = new File("C:\\ravi\\non-existing.no");
Properties pro = System.getProperties();
pro.put("file", file);
System.out.println(pro.contains(file)); //PRINTS TRUE , AS EXPECTED
File file2 = file;
System.out.println(pro.contains(file2)); //PRINTS TRUE , AS EXPECTED
File file3 = new File("C:\\ravi\\non-existing.no");
System.out.println(pro.contains(file3)); //EXPECTED FALSE , BUT PRINTS TRUE
File file4 = new File("C:\\ravi\\non.no");
System.out.println(pro.contains(file4)); //PRINTS FALSE , AS EXPECTED
我期待Properties
检查 的存在File
,但这似乎不起作用。有人可以帮我解释为什么file3
不能按我的预期工作。