• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting java.lang.NoSuchMethodError: main error! thanks =)

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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!
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
winnie Lim
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
winnie Lim
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks! will read through and try to understand on my own.

you guys have been a great help thanks a million!!!
 
Campbell Ritchie
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confident that link will supply all the information you need.

And . . . you're welcome
 
Hot dog! An advertiser loves us THIS much:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic