Results 1 to 4 of 4
- 05-04-2012, 05:07 PM #1
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Passing enums through (as parameters)
Hello,
I am new to these forums and brand new to Java..
I'm trying to compile this code with no success.. I am at a loss as to what I could be doing wrong - perhaps some feedback might help me out.
It's giving me an error reading:Java Code:public class Parliament { // Each member of parliament is assigned the following: // Name, Political Party, and Province enum Party { CON, NDP, LIB, GRN, BQC, IND } enum Province { ON, QC, NS, NB, MB, BC, PE, SK, AB, NL, NT, YT, NU } String strName; Party enmParty; Province enmProvince; public void Parliament(String strName, Party enmParty, Province enmProvince) { this.strName = strName; this.enmParty = enmParty; this.enmProvince = enmProvince; System.out.println("Name: " + strName); System.out.println("Party: " + enmParty); System.out.println("Province: " + enmProvince); } }
Forgive me if I'm missing something very obvious.Exception in thread "main" java.lang.NoSuchMethodError: main
- 05-04-2012, 05:11 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: Passing enums through (as parameters)
Erm, just a wild guess: your class is missing a static public void main(String[] args) method? (it can't be run by the JVM)
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 05-04-2012, 05:43 PM #3
Member
- Join Date
- May 2012
- Posts
- 2
- Rep Power
- 0
Re: Passing enums through (as parameters)
Thanks!
And forgive my lack of understanding.. I'm used to VB, and other less common languages (Turing, etc).. all of which seem much, much more simple. (In addition - I have no access to any IDEs)
Basically, my question now becomes - how do you call a method from the 'public static void main(String[] args)?
If I wanted to call the Parliament method for user input, I'm thinking it would be similar to:
Hopefully I'm not too far off..Java Code:Parliament Member1 = new Parliament();
Thank you for your much needed help.
- 05-04-2012, 07:46 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: Passing enums through (as parameters)
So now you know that the JVM searches for that main( ... ) method to start executing your program. The statements in the body of that method can do what they want, e.g. create new objects and call methods on that object. Your initialization of the Member1 reference variable makes a fine statement in the body of your main( ... ) method.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
passing parameters to graphics
By jforce93 in forum New To JavaReplies: 6Last Post: 02-04-2010, 03:45 AM -
passing parameters to next jsp using javascript
By sridevisala in forum New To JavaReplies: 0Last Post: 11-20-2009, 05:34 AM -
[SOLVED] Passing parameters
By robocop in forum New To JavaReplies: 3Last Post: 03-03-2009, 10:16 PM -
passing parameters to paint mtd
By themburu in forum Java AppletsReplies: 3Last Post: 07-14-2008, 08:15 PM -
JNI - passing and returning parameters by value
By java_to_c in forum New To JavaReplies: 0Last Post: 01-31-2008, 08:49 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks