• Post Reply Bookmark Topic Watch Topic
  • New Topic

Flow of a program with an array  RSS feed

 
Noble Graves
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anArray[0] = 5.0; // initialize first element
anArray[1] = 4.4; // initialize second element
anArray[2] = 1.9; // etc.
anArray[3] = 2.9;
anArray[4] = 3.4;
anArray[5] = 3.5;

//print the original array order
System.out.println("Element at index 0: "+anArray[0]);
System.out.println("Element at index 1: " + anArray[1]);
System.out.println("Element at index 2: " + anArray[2]);
System.out.println("Element at index 3: " + anArray[3]);
System.out.println("Element at index 4: " + anArray[4]);
System.out.println("Element at index 5: " + anArray[5]);
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noble Graves wrote:anArray[0] = 5.0; // initialize first element
anArray[1] = 4.4; // initialize second element
anArray[2] = 1.9; // etc.
anArray[3] = 2.9;
anArray[4] = 3.4;
anArray[5] = 3.5;

//print the original array order
System.out.println("Element at index 0: "+anArray[0]);
System.out.println("Element at index 1: " + anArray[1]);
System.out.println("Element at index 2: " + anArray[2]);
System.out.println("Element at index 3: " + anArray[3]);
System.out.println("Element at index 4: " + anArray[4]);
System.out.println("Element at index 5: " + anArray[5]);

Did you have a question about this because it seems to have nothing to do with the original post ?
 
Noble Graves
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stuart A. Burkett wrote:
Noble Graves wrote:anArray[0] = 5.0; // initialize first element
anArray[1] = 4.4; // initialize second element
anArray[2] = 1.9; // etc.
anArray[3] = 2.9;
anArray[4] = 3.4;
anArray[5] = 3.5;

//print the original array order
System.out.println("Element at index 0: "+anArray[0]);
System.out.println("Element at index 1: " + anArray[1]);
System.out.println("Element at index 2: " + anArray[2]);
System.out.println("Element at index 3: " + anArray[3]);
System.out.println("Element at index 4: " + anArray[4]);
System.out.println("Element at index 5: " + anArray[5]);

Did you have a question about this because it seems to have nothing to do with the original post ?


Yeah i need to know how does this code works? I mean what is the flow of the code.
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noble Graves wrote:Yeah i need to know how does this code works? I mean what is the flow of the code.

What exactly do you not understand ? The flow is from top to bottom. It initialises an array with some values and then prints them out.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!