- /**
- * Demonstrates using a loop to fill and
output
- * an array.
- *
- * @author TK Rogers
- * @version 12 - 17 - 10
- */
- public class LoopsArraysDemo {
- public static void main (
) {
-
int array [ ] = new int [ 8 ] ;
// Creates an array for 8 items.
-
-
for ( int x = 0; x < 8; x++ ) {
-
array [x] = x ; // Fills the array with integers from 0
to 7.
-
}
-
-
for ( int x = 0; x < 8; x++ ) {
-
System.out.println ( array [ x ] ) ; // Outputs the array.
-
}
-
- System.out.println ( array ) ; // Outputs
only the array's
-
// hexadecimal memory address.
- }
- }