Below is my program code:
public class TestLagi
{
public static void main (String [] args)
{
Test myTest= new Test("what an ordinary world");
myTest.coba();
Here is my class code:
import java.util.Scanner;
public class Test
{
private String word;
private Scanner input;
public Test (String word)
{
word = "";
input = new Scanner(word);
}
public void coba()
{
while (input.hasNext())
{
String word = input.next();
System.out.println(word);
}
Iam trying to print several words on different line based on the string using the hasNext() method here, but why it wont work? Where did I make a mistake? I only can use the hasNext() and the next() method..
Thanks
System.out.println("failed");
}
}
}
}
2006-10-27
05:30:47
·
2 answers
·
asked by
?
1
in
Computers & Internet
➔ Programming & Design