Skip to content

Instantly share code, notes, and snippets.

@yonatanm
Last active September 14, 2017 15:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yonatanm/af7b009dfed3ba6d06b563363928157f to your computer and use it in GitHub Desktop.
Save yonatanm/af7b009dfed3ba6d06b563363928157f to your computer and use it in GitHub Desktop.
Explain why (r1 == true) and (r2==false) ?
Set<URL> mySet = new HashSet<>();
mySet.add(new URL("https://my.outbrain.com"));
boolean r1 = mySet.contains(new URL("https://my.outbrain.com")); // Returns true
System.out.println("r1 = " + r1);
Thread.sleep(60 * 1000); // sleeping for 1 minute
boolean r2 = mySet.contains(new URL("https://my.outbrain.com")); // Return false
System.out.println("r2 = " + r2);
// why (r1 != r2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment