I am getting an unexpected output from Properties.contains()
...
This is my code...
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
I am expecting the Properties
to check for the existance of the File
, however this doesn't seem to work. Could someone please help me explain why file3
doesn't work as I expect.