1

I have an assignment to do, and my teacher provided me with a part of code which could help doin said assignment. But I am unsure of one part of it;

String utenRepetisjon(String tekst){

    String resultat = ""; 
    for (int i = 0; i < tekst.length(); i++){
        if (!tekst.charAt(i), resultat){ //Here I need help, if someone could be an angel and explain to me what this line does: !tekst.charAt(i), resultat). I know that it it something like: if the char at spot i in the string is not present, then something, but what's up with the comma?
            resultat += tekst.charAt(i); 
        }
    }
    return resultat; 

}
Makri
  • 331
  • 2
  • 4
  • 15

1 Answers1

0

You're right to be confused. It looks like someone forgot what language they were using and tried to insert some C++ syntax. This will not compile in Java.

Probably what was intended was to compare tekst.charAt(i) to something, and proceed if that comparison returned false. However, that comma and floating identifier are just bad syntax, and simple do not compile.

Henry Keiter
  • 16,863
  • 7
  • 51
  • 80