1

私にはやるべき課題があり、先生はその課題を行うのに役立つコードの一部を提供してくれました。しかし、私はその一部について確信が持てません。

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; 

}
4

1 に答える 1

0

あなたが混乱するのは正しいです。使用している言語を誰かが忘れて、C++ 構文を挿入しようとしたようです。これは Java ではコンパイルされません。

おそらく意図したのはtekst.charAt(i)、何かと比較し、その比較が false を返した場合に続行することでした。ただし、そのコンマと浮動識別子は構文として正しくなく、simple はコンパイルされません。

于 2013-10-16T19:50:13.580 に答える