Results 1 to 10 of 10
Thread: Error: Identifier Expected
- 08-29-2012, 10:32 PM #1
Member
- Join Date
- Aug 2012
- Posts
- 6
- Rep Power
- 0
Error: Identifier Expected
It applies to line 20.
When I put main after void, it gives me another error that says method main already defined in class (____) What can I put after void to stop the compile error and make it so the lines after it show up?
//NAME
//CLASS
//SEMESTER
//PROJECT NAME
public class mynameincode{
public static void main(String[]args) {
PrinHeading();
}
public static void PrinHeading () {
System.out.println ("name");
System.out.println ("Class");
System.out.println ("semester");
System.out.println ("project name");
}
public static void main (String[]args) {
System.out.println("garbage");
System.out.println("garbage");
System.out.println("garbage");
System.out.println("garbage");
System.out.println("garbage");
System.out.println("garbage");
System.out.println("garbage");
}
}Last edited by vickyv200; 08-29-2012 at 10:35 PM.
- 08-29-2012, 11:04 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Re: Error: Identifier Expected
Your class has duplicate method definitions (eg main). Create unique method names/definitionsWhat can I put after void to stop the compile error and make it so the lines after it show up?
- 08-29-2012, 11:49 PM #3
Re: Error: Identifier Expected
Why do they call it rush hour when nothing moves? - Robin Williams
- 08-31-2012, 12:32 AM #4
Member
- Join Date
- Aug 2012
- Posts
- 6
- Rep Power
- 0
Re: Error: Identifier Expected
Last edited by vickyv200; 08-31-2012 at 12:35 AM.
-
Re: Error: Identifier Expected
What "lines after" are you talking about? Your code as written will only print what you see. Perhaps you should post your updated code and explain what you're trying to do.
-
Re: Error: Identifier Expected
Please post your code here. You're asking for free advice, so please try to make it as easy as possible to help you. Also again, please let us know what you expect the output to be.
- 08-31-2012, 01:14 AM #7
Member
- Join Date
- Aug 2012
- Posts
- 6
- Rep Power
- 0
Re: Error: Identifier Expected
Alright I'm not sure what the problem is with the actual java file.
I expect the output to be 7 lines of the word garbage.
Java Code://NAME //CLASS //SEMESTER //PROJECT NAME public class boo{ public static void main(String[]args) { PrinHeading(); } public static void PrinHeading () { System.out.println ("name"); System.out.println ("Class"); System.out.println ("semester"); System.out.println ("project name"); } public static void secondary (String[]args) { //Everything after this won't show up, only the print heading. System.out.println("garbage"); System.out.println("garbage"); System.out.println("garbage"); System.out.println("garbage"); System.out.println("garbage"); System.out.println("garbage"); System.out.println("garbage"); } }Last edited by vickyv200; 08-31-2012 at 09:13 AM.
-
Re: Error: Identifier Expected
Walk through each line of your program as if it were running to get the flow of its logic, starting with the main method. You're asking why the code in the secondary method never gets called. Ask yourself as you're waking through your code -- "where do I call this method?"
- 08-31-2012, 09:20 AM #9
Member
- Join Date
- Aug 2012
- Posts
- 6
- Rep Power
- 0
- 08-31-2012, 10:05 AM #10
Moderator
- Join Date
- Apr 2009
- Posts
- 10,447
- Rep Power
- 16
Similar Threads
-
<identifier expected> error. please help!
By christopherx in forum AWT / SwingReplies: 9Last Post: 10-02-2011, 10:23 PM -
Error:identifier expected(Help!)
By chhoton in forum New To JavaReplies: 8Last Post: 09-22-2009, 04:42 PM -
getting identifier expected error . help me !
By victorkeath in forum New To JavaReplies: 3Last Post: 11-07-2008, 05:49 PM -
Identifier expected error
By vasu18 in forum New To JavaReplies: 1Last Post: 01-01-2008, 05:49 PM -
Error: <identifier> expected
By barney in forum AWT / SwingReplies: 2Last Post: 07-31-2007, 07:38 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks