0

How Can I Display The Number Of The Array in The Output using a Loop???? Example (I Want the Output 2 B Like This) "Please Enter the Array's Element Number 0:" "Please Enter the Array's Element Number 1:" and So On.....

7th Aug 2016, 10:06 PM
Mahmoud Hamdy Abaza
Mahmoud Hamdy Abaza - avatar
4 odpowiedzi
+ 3
when you are using loop to print something just print that variable as well.. e.g. for(i=0;i<4;i++){System.out.println("please enter array element" + i); }
7th Aug 2016, 10:14 PM
Sachet Saxena
Sachet Saxena - avatar
+ 3
Use a for loop: for(int i; i < array.length; i++){ System.out.println("Please Enter the Array's Element Number " + i + ":"); array[i] = scanner.nextInt(); }
7th Aug 2016, 10:19 PM
Lordeblader
+ 1
Oops I forgot: for(int i = 0;... ^
8th Aug 2016, 10:44 AM
Lordeblader
+ 1
@Fabián Haha...Don't Worry About it I'm not That Dumb xP
8th Aug 2016, 11:28 AM
Mahmoud Hamdy Abaza
Mahmoud Hamdy Abaza - avatar