storing input from an applet into an array

Posted on 2003-03-14
Medium Priority
Last Modified: 2011-09-20
I have to create an applet where i have two different text fields and need to store the input from each field into an array. Please help!!! Also, how can i initialize the number of elements in the array just from the number of times the user clicks the "enter" button?
Question by:mars0037
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 92

Expert Comment

ID: 8139989
String[] entered = new String[] { tf1.getText(), tf2.getText() };

> how can i initialize the number of elements in the array
> just from the number of times the user clicks the "enter" button?

Object[] myaaray = new Object[ntimes];


Expert Comment

ID: 8139999

Try to do the following things...

TextField t = new TextField();
String Test[] = new String[50];

in the main()

Test[0] = t.getText();

This is the easy way of doing it... :o)

And about the User 'ENTER' press, try with an int that keeps track of the number of times the 'ENTER' button been pressed...

Accepted Solution

wide_awake earned 750 total points
ID: 8141105
Another option is to use a Vector instead of an array, that way you can use Vector.add(text) instead of specifying a fixed-size array.


Author Comment

ID: 8141443
i think i'll try the vector. thanks!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question