| Author |
getting java.lang.NoSuchMethodError: main error! thanks =)
|
winnie Lim
Greenhorn
Joined: Feb 10, 2009
Posts: 16
|
|
i keep getting java.lang.NoSuchMethodError: main
Exception in thread "main" when i try to run it but it complies fine. Can anyone advise? Thanks!
Also i would like to ask how would i save the student name and ID into an arraylist and retrieve it from the arraylist to delete? Thanks for help!
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9948
|
|
|
um.... you don't have a main method in the code you posted. a class is not require to have a main to compile, only to run.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Sagar Rohankar
Ranch Hand
Joined: Feb 19, 2008
Posts: 2896
|
|
winnie Lim wrote:
Also i would like to ask how would i save the student name and ID into an arraylist and retrieve it from the arraylist to delete? Thanks for help! 
Id is a Key and Student name is values, that's sound good for Map collections
|
[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
|
 |
winnie Lim
Greenhorn
Joined: Feb 10, 2009
Posts: 16
|
|
is there anything wrong with my School class?
i can't seem to call the addStudent, removeStudent, methods in my public class SchoolApp. i get error "cannot find symbol method addStudent();"
thanks alot for the java.lang.NoSuchMethodError! solved!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
You appear to be calling addStudent() etc from another class, SchoolApp, and SchoolApp hasn't got an addStudent() method.
You need to create a School object in that main method, then invoke the methods on that object.
By the way: your addStudent method in the School class doesn't seem to do anything. It asks for the Student's name, but doesn't do anything with it. It that because the class is incomplete?
|
 |
winnie Lim
Greenhorn
Joined: Feb 10, 2009
Posts: 16
|
|
Campbell Ritchie wrote:You appear to be calling addStudent() etc from another class, SchoolApp, and SchoolApp hasn't got an addStudent() method.
You need to create a School object in that main method, then invoke the methods on that object.
By the way: your addStudent method in the School class doesn't seem to do anything. It asks for the Student's name, but doesn't do anything with it. It that because the class is incomplete?
yes the code is incomplete... i'm supposed to store it into a arraylist and retrieve it.
sorry to ask but can you teach me how to create a School object in the main method? I know it sounds stupid but i really am new and its a pressing assignment.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
How do you create a new object of any class? You do the same with the School class.
And please don't go saying questions are urgent.
|
 |
winnie Lim
Greenhorn
Joined: Feb 10, 2009
Posts: 16
|
|
Campbell Ritchie wrote:How do you create a new object of any class? You do the same with the School class.
And please don't go saying questions are urgent.
erm... i really don't know how to create a new object of anything! i already tried looking through all the online tutorials but i really can't get what they mean or what how the object class in created. Please if you can, just help me out here.
|
 |
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
|
|
This site discusses how to create a new object. It has some things that are out of your scope, but it should give a decent description on creating an object.
Creating Objects
|
SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
|
 |
winnie Lim
Greenhorn
Joined: Feb 10, 2009
Posts: 16
|
|
hey thanks!
but after i declare eg School sch = new School ();
what do i do to invoke the methods in the object?
|
 |
W. Joe Smith
Ranch Hand
Joined: Feb 10, 2009
Posts: 710
|
|
The longer I post on this forum, the more people will realize I'm full of links!
Link
That should describe how to invoke the methods of an object.
|
 |
winnie Lim
Greenhorn
Joined: Feb 10, 2009
Posts: 16
|
|
thanks! will read through and try to understand on my own.
you guys have been a great help thanks a million!!!
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32675
|
|
I am confident that link will supply all the information you need.
And . . . you're welcome
|
 |
 |
|
|
subject: getting java.lang.NoSuchMethodError: main error! thanks =)
|
|
|