View Single Post
  #1 (permalink)  
Old 11-26-2009, 05:28 PM
enzyme enzyme is offline
Member
 
Join Date: Nov 2009
Posts: 2
Rep Power: 0
enzyme is on a distinguished road
Default Looping Array Elements
Hi,
I'm giving a go at Java and found a problem I'm unable to solve here..

I want to display all the elements in an array. So, I did this:

Code:
public class Goober {
	public static void main(String[] args) {
		double[] classArray = {23.44, 33.23, 88.66, 34.34, 55.55, 33.44};
		classArray = new double[5];
		for (int i = 0; i < classArray.length; i++) {
			System.out.println(classArray[i]);
		}
	}
}
The output is this:

0.0
0.0
0.0
0.0
0.0

What is it that I've done wrong?
I'm using OpenJDK 6 on Arch Linux.
Reply With Quote