Skip to main content
deleted 5 characters in body; edited tags; edited title
Source Link
Michael Myers
  • 192.6k
  • 47
  • 301
  • 297

what does What does this statement mean??

I am a beginner in Java and do not understand what if(!s.add(a)) means in this code excerpt:

Set<String> s = new HashSet<String>(); for(String a:args) { if(!s.add(a)) System.out.println("Duplicate detected:"+a); } 

what does this statement mean??

I am beginner in Java and do not understand what if(!s.add(a)) means in this code excerpt:

Set<String> s = new HashSet<String>(); for(String a:args) { if(!s.add(a)) System.out.println("Duplicate detected:"+a); } 

What does this statement mean?

I am a beginner in Java and do not understand what if(!s.add(a)) means in this code excerpt:

Set<String> s = new HashSet<String>(); for(String a:args) { if(!s.add(a)) System.out.println("Duplicate detected:"+a); } 
added 8 characters in body; edited tags; added 28 characters in body
Source Link
oxbow_lakes
  • 134.5k
  • 56
  • 323
  • 451

I am beginner in Java.I can and do not getunderstand what the **if(!s.add(a))**mean??if(!s.add(a)) means in this code excerpt:

Set<String> s = new HashSet<String>(); for(String a:args) {  if(!s.add(a))   System.out.println("Duplicate detected:"+a); } 

I am beginner in Java.I can not get what the **if(!s.add(a))**mean??

Set<String> s = new HashSet<String>(); for(String a:args) if(!s.add(a))  System.out.println("Duplicate detected:"+a); 

I am beginner in Java and do not understand what if(!s.add(a)) means in this code excerpt:

Set<String> s = new HashSet<String>(); for(String a:args) {  if(!s.add(a)) System.out.println("Duplicate detected:"+a); } 
Source Link
Johanna
  • 27.7k
  • 43
  • 94
  • 118

what does this statement mean??

I am beginner in Java.I can not get what the **if(!s.add(a))**mean??

Set<String> s = new HashSet<String>(); for(String a:args) if(!s.add(a)) System.out.println("Duplicate detected:"+a);