02-11-2008, 02:34
|
|
|
חבר מתאריך: 22.10.08
הודעות: 15
|
|
[עזרה] לא מצליח להבין מה הבעיה JAVA
אני מנסה לעשות איזה משהו קטן ומשהו בקוד שלי לא עובד:
קוד:
public class FindThe
{
public static void main (String[] args)
{
String line, word, lcWord;
int pos = 0, lastPos;
System.out.print ("Enter a line of text: ");
line = Stdin.readLine ();
while (pos < line.length ())
{
while (line.charAt (pos) == ' ')
{
pos++;
}
lastPos = line.indexOf (' ', pos + 1);
if (lastPos == -1)
{
lastPos = line.length ();
}
word = line.substring (pos, lastPos);
lcWord = word.toLowerCase ();
if (lcWord.indexOf ("the") != -1)
{
System.out.println (word);
}
pos = lastPos;
} // while (true)
}
}
מה הבעיה?
|