wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Please help!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Please help!!!" Watch "Please help!!!" New topic
Author

Please help!!!

Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
Hi!
Can't seem to manage the following code:

public class Expert extends User {
private String category;
private int categoryIndex;

public Expert(String aName, int aUserID,
String aTelephoneNo, String category) {
super(aName, aUserID, aTelephoneNo);
this.category = category;
}

private List categoryList = new ArrayList();


public String getCategory(int categoryIndex) {
String empty = "";
for (int i = 0; i < categoryList.size(); i++) {
if(i==categoryIndex) {
empty = "" + categoryList.get(i);
}
}
return empty;
}

public void setCategory(String category) {
this.category = category;
}

public String toString() {
return super.toString() + "\tCategory: " + category;
}
}

Any help would be greatly appreciated.
Thanks!
tanja klaut
Greenhorn

Joined: Aug 22, 2003
Posts: 4
hi vlada den,

where is the problem? what do you want the class to do that it is not doing or what is it doing wrongly?


we are the robots
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
Originally posted by Vlada Den:
Can't seem to manage the following code:
...
Any help would be greatly appreciated.
Thanks!


How are you trying to "manage" it? Do you mean you don't know how to create an application from it? You'd need a main() method.

Are you getting compilation errors? What are they?

Can you compile but get runtime errors? What happens?

Do you get an Exception? What is it?
[ January 30, 2005: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
I'm doing it in NetBeans, so the main method will be added, when I create A GUI. I get a compilation error in this line:

private List categoryList = new ArrayList();

Can't find out what's wrong here.
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
Originally posted by Vlada Den:
I get a compilation error in this line:

private List categoryList = new ArrayList();
I'm going to guess (please don't make us guess!) that the errors you're getting areIf so, this is telling you that your Expert class doesn't define List and ArrayList.

If a class needs to use another class, it must import it. Import statements tell the compiler where to find the definition for another class that you want to use. They go at the top of the file after the package statement (if any) and before the class or interface definitions. They look like this:Your job is to find where the List and ArrayList classes are located. If you don't know, use the JavaDocs to find out.
[ January 30, 2005: Message edited by: David Harkness ]
Vlada Den
Ranch Hand

Joined: Dec 19, 2004
Posts: 32
Now I see...
Thank you so much, David.
And I'll try to ask more to-the-point questions next time.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help!!!