0
why is it not running? import java.util.Scanner; public class Myclass{ public static void main(String [] args){ Scanner in = new Scanner(System.in); String a; int b; System.out.println("enter a word"); a = in.nextLine(); System.out.println("enter repetition") b = in.nextInt(); for ( int = 0; x < b; x = x++) System.out.println(a); } }
8 Antworten
+ 3
instead of in try another name for scanner variable. because in is already a static member of System class. and where is variable in ur for loop have u forget to write int x=0;
+ 3
The problem seems to be a logical error. I suppose it is with the for loop control variable.
+ 1
you didn't declare x and instead gave a value to the data type int
+ 1
Where on earth is "x"???
+ 1
you could have used:
Scanner sc=new Scanner (System.in);
+ 1
You see, you can name your Scanner object anything you like
0
thanks, but what do you think suits the best instead of using "in"?
0
n