Newbie question: handling arrays in separate class

T

Tom

Hey,

I'm new to Java and looking for solution to the following question.
In my code I want to keep all my data in the arrays of strings in a
separate class.
I can not find a way to construct such a class that would return on
request a specific string from a specific array.

I looked through the java groups any did not find anything that would
help me.
If it's a trivial question please give me at least some guideline
where to look for answer.

By the way, sorry for my language

Tom
 
C

Chris Smith

toto- said:
I'm new to Java and looking for solution to the following question.
In my code I want to keep all my data in the arrays of strings in a
separate class.
I can not find a way to construct such a class that would return on
request a specific string from a specific array.

I looked through the java groups any did not find anything that would
help me.
If it's a trivial question please give me at least some guideline
where to look for answer.

Unfortunately, your question is rather vague. What data are you trying
to store in these arrays? Is there a specific set of arrays, or do you
need to be able to add or remove arrays of strings at any time? What
identifying information would you use to try to obtain an array; i.e.,
are they numbered or named?

With some more information, perhaps someone could help. Nevertheless,
it appears you're headed in the wrong direction with your design. The
goal should be to create an appropriate OO model of the application
data, rather that storing all of your data in some general-purpose data
structure. That's up to you, though.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
T

Tom

I'm writing a sort of dicionary application for mobile phone and I though of
having one class with all the data i.e texts sorted in 1dim. arrays of
strings. The class should return one element from an array after providing a
name of an array and a number of element in that array.
That's the problem that I'm facing now and looking for solution.

Tom
 
C

Chris Smith

I'm writing a sort of dicionary application for mobile phone and I though of
having one class with all the data i.e texts sorted in 1dim. arrays of
strings. The class should return one element from an array after providing a
name of an array and a number of element in that array.
That's the problem that I'm facing now and looking for solution.

See the java.util.Map interface, and its concrete implementations
TreeMap and HashMap.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
O

Oscar kind

Tom said:
I'm writing a sort of dicionary application for mobile phone and I though of
having one class with all the data i.e texts sorted in 1dim. arrays of
strings. The class should return one element from an array after providing a
name of an array and a number of element in that array.
That's the problem that I'm facing now and looking for solution.

In that case, an alternative is to use a ResourceBundle. It allows you to
easily find texts for labels, as used in internationalized applications.

In you case:
- The labels are not that important, but could be useful.
- As you can enumerate the labels (keys), you can add suffixes to the
labels: original, translation, description
- You can even:
- Use a prefix that specifies the language
- Use a suffix to destinguish between words and descriptions
- Use unified labels to couple words:
english.house.word=House
dutch.house.word=Huis
french,house.word=Maison
To translate from english to dutch, you'd need these labels:
english.house.word
english.house.description
dutch.house.word
 
T

Tom

Thanks for guidelines.
As it was said somewhere else before: I'm learning Java by programing.
But it's easier when you know where to look.

Tom
 
T

Tom

Thanks for guidelines.
As it was said somewhere else before: I'm learning Java by programing.
But it's easier when you know where to look.

Tom
 
T

Tom

Uzytkownik "Chris Smith said:
See the java.util.Map interface, and its concrete implementations
TreeMap and HashMap.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

My program is for J2ME environment that implements Connected, Limited Device
Configuration CLDC1.0
If I understand it well it doesn't include TreeMap and HashMap classes in
the java.util. The only suitable class that I see would be Hashtable, but it
is created dynamically and I guess will not help me as I have problem with
control of size of heap memory (very limited). My program is currently
working buy all objects (screens, form, lists) are created dynamically at
the beginning, heap mem. is almost full which limits my program. (I know it
is wrong approach - I'm a beginner)
Thus, I thought of keeping all texts in static arrays in one class (a sort
of dictionary class) and taking only necessary texts from that class and use
where necessary.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top