print array values in java using for loops, while loops, and do while loops
print elements of array using for loop:
int a[]={7,8,6,5,9}; System.out.println("print array elements using for loop:"); for(int i=0;i<=4;i++) { System.out.println(a[i]); }
print array values using while loop:
int arr[]={5,6,9,8,7}; int i=0; while(i<=4) { System.out.println(arr[i]); i++; }
print array values using do while loop:
int arr[]={5,4,7,3,8}; int i=0; do { System.out.println(arr[i]); i++; } while(i<=4);
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
print elements of array using for loop:
print array values using while loop:
print array values using do while loop:
need an explanation for this answer? contact us directly to get an explanation for this answer