0
Can I have array with user's inputs?
5 odpowiedzi
+ 4
integer array
public class TakingInput {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
System.out.println("enter number of elements");
int n=s.nextInt();
int arr[]=new int[n];
System.out.println("enter elements");
for(int i=0;i<n;i++){//for reading array
arr[i]=s.nextInt();
}
for(int i: arr){ //for printing array
System.out.println(i);
}
}
}
+ 1
yes
0
yes
0
yes it is possible. you can do it with the
help of 'for' loop .
0
can you tell mr how? i tried many syntaxes (for loop too) but nothing worked..