Solved

Howto create array of String "structures" in jsp?

Posted on 2009-04-07
3
419 Views
Last Modified: 2012-05-06
This is probably very elementary, but how would I create an arrary of structures in jsp? Here's the C version of what I want:

typedef struct {
    char     *abbrev;
    char     *name;
} STATES ;

STATES states = {"AL","Alabama", ... };

states[0].name // references "Alabama"

I don't want to create any external class files, etc.
0
Comment
Question by:jmarkfoley
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 24092535
you could create a 2d array

String[][] states = new String[][] { {"AL", "Alabama"}, "{"XX", "Mars"}};

0
 
LVL 12

Expert Comment

by:basav_com
ID: 24092880
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 24092931
objects - thanks, I used your solution and it was simple. I thought there might be something a bit more elegant than a 2-D array, but I suppose that also means far more complex.

basav_com - thanks for the links, although I didn't see any actual code on the HashMap list, but maybe I didn't look hard enough.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

747 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now