2013-10-16 57 views
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

这不会编译。 – qqilihq

+0

这可能不会编译 –

+2

这将无法编译。必须是错字。 –

回答

0

你是对的混淆。看起来有人忘记了他们正在使用的语言,并试图插入一些C++ syntax。这不会在Java中编译。

可能是打算将tekst.charAt(i)与某些东西进行比较,如果该比较返回错误,则继续。但是,该逗号和浮动标识符只是不好的语法,简单的不编译。

相关问题