I am trying to read input in main function as well as different functions, for that, I am creating two different Scanner and it is giving me an error but if I take input only in main function and pass the value in the different function it does not gives error then, what I am missing here?. I am a beginner in java.
import java.util.Scanner;
public class abc{
public static void fun(){
Scanner read = new Scanner(System.in);
int a,b,c;
a=read.nextInt();
b=read.nextInt();
c=read.nextInt();
// some code
}
public static void main(String[] args){
Scanner read=new Scanner(System.in);
int t=read.nextInt();
while(t>0){
fun();
t--;
}
}
}