I guess this is pretty easy to spot but I don't know how to fix it, can anyone tell me what's wrong in the code? how can I get the scanner to run inside the read() method ???
import java.util.*;
public class NewClass {
Scanner ms = new Scanner (System.in);
public static boolean printComma = false;
public static void main(String[] args) {
read();
}
public static void read(){
int x;
System.out.println("-----");
x= ms.nextInt();
if(x!=0){
read();
if(printComma)System.out.println(" , ");
System.out.print(x);
printComma=true;
}
}
}
import java.util.*;
public class NewClass {
Scanner ms = new Scanner (System.in);
public static boolean printComma = false;
public static void main(String[] args) {
read();
}
public static void read(){
int x;
System.out.println("-----");
x= ms.nextInt();
if(x!=0){
read();
if(printComma)System.out.println(" , ");
System.out.print(x);
printComma=true;
}
}
}