im trying with arrayList now..
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
im trying with arrayList now..
Last edited by emkoirl; April 8th, 2011 at 02:14 PM.
You'll need to use an ArrayList realistically unless you know how many times the user is going to click
ArrayList<String> myStringList = new ArrayList<String>();
To add to an ArrayList, type myStringList.add("Hello World");
To retrive from the ArrayList, for example, the first entry, you type myStringList.get(0);
Click through these examples if you're still unclear/
Getting an Element : ArrayListCollectionsJava Tutorial
Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code
Hello buddy, I believe that your problem lies in the fact that you havent declared a size for the array.
public static void main(String[] args) { String[] myArr = new String[20]; int i = 0; Customer cust = new Customer(); cust.setForename("Andrew"); if (cust.getForename()=="Andrew") { currentString = cust.getForename(); myArr[i] = currentString; } }
That works and seems to be acheiving what you were after,
Regards,
edit: NVM i fixed it.. i was initialising the array everytime the user clicked a button so obviously it gave me an error
thx for the help
Last edited by emkoirl; April 8th, 2011 at 02:18 PM.