Hi, when I write java code, how does the class detect the input cases? I tried to write input in the main class and call my function, but that doesn’t work.
Regarding input
you have to define your scanner in your main/globally
you can do something like this in the main:
Scanner sc = new Scanner(System.in);
int n= sc.nextInt();
String[] arr= new String[n];
for( int i=0;i<n;i++){
String str = sc.nextLine();
arr[i]=str;
}