Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

learning arrays in java

843789Jul 28 2009 — edited Jul 29 2009
Hello, I'm trying to learn arrays.
This is a simple java class that

1. defines an array private static to be accesible from within the whole class
2. fills array of int
3. prints content of array of int

I do not understand why, but it never gets into the foor loop to fill in the array... it should show me

4 (vector.lenght)
0 (vector[0])
1 (vector[1])
2 (vector[2])
3 (vector[3])

But I only get

4 (vector.lenght)

public class Vector {

private static int[] vector = new int[4];

    public static void main (String[] args) {

        System.out.println(vector.length);

        //fill
        for (int i = 0; i > vector.length; i++) {
            System.out.println(i);
            vector=i;
}

//print
for (int i = 0; i > vector.length; i++) {
System.out.println("Vector position " + i + " = " +vector[i]);
}
}
}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2009
Added on Jul 28 2009
20 comments
156 views