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!

Array Lists

807597Feb 2 2005 — edited Feb 2 2005
I am trying to initialize an array list in my program.
I have imported import java.util.*;
import java.util.ArrayList;

I have a variable "private ArrayList arrayofSquares"

in my constructor I have this "arrayofSquares=new ArrayList();"

I want to add numbers like 1,2,3 and 2,3,4 to each index of the list down futher in a for loop.

My complier gives the error "non ststic variable arrayofSquares cannot be referenced from a static context arrayofSquares=new ArrayList();"

Can anyone please tell me where i am going wrong
Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 2 2005
Added on Feb 2 2005
9 comments
106 views