View Single Post
  #1 (permalink)  
Old 04-21-2008, 04:02 PM
Zebra's Avatar
Zebra Zebra is offline
Member
 
Join Date: Apr 2008
Location: Louisville, Indiana/Kentucky
Posts: 64
Zebra is on a distinguished road
[SOLVED] Arrays/for-loops (easy) need help.
Hey I am suppose to rewrite the following code but make it so that the array is initialized on one line of code and a loop is used to display for the results.

Code:
class OneDimensionArray { public static void main(String args[]) { // Declare and allocate space int myarray[] = new int[4]; // Initialize elements myarray[0] = 33; myarray[1] = 71; myarray[2] = -16; myarray[3] = 45; // Display length System.out.println("myarray.length = " + myarray.length); // Display elements System.out.println(myarray[0]); System.out.println(myarray[1]); System.out.println(myarray[2]); System.out.println(myarray[3]); } }
__________________
I am a Java n00b.
Reply With Quote
Sponsored Links