210k views
0 votes
Write a statement that reads a word from standard input into firstWord. Assume that firstWord. has already been declared as a String variable. Assume also that stdin is a variable that references a Scanner object associated with standard input.

User Shoba
by
6.2k points

1 Answer

4 votes

// taking the super class object to take input

Scanner stdlin = new Scanner(System.in);

// saving it in the firstWord

// assuming that the firstWord is already declared as mentioned in question

firstWord = stdlin.nextString();

//Java uses nextstring method of class scanner to take a word as input.

User Javed Ahamed
by
6.7k points