Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2016
    Posts
    47
    Rep Power
    0

    Default Problem with the main method

    I have 2 pics attached of my code and also the error message. The 2nd attachment is hyperlinked.


    1. What is wrong with my main method?

    2. On line 12, I have a "multiple markers at this line" error. I also can't tell what is wrong with this line. I added the import statement and I still have an error.

    3. Also, after adding 3 java files (tabs) and creating two packages, the save button is still grayed out. Why can't I save my work?
    Attached Thumbnails Attached Thumbnails Problem with the main method-java-error.jpg   Problem with the main method-error-message.png  
    Last edited by allDogsAreGood; 09-27-2018 at 06:08 AM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Problem with the main method

    The editor is folding; i.e. there is more code in that class than we can see. hint: click that little blue minus sign on lign nine to unfold the code.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Join Date
    Oct 2016
    Posts
    47
    Rep Power
    0

    Default Re: Problem with the main method

    Quote Originally Posted by JosAH View Post
    The editor is folding; i.e. there is more code in that class than we can see. hint: click that little blue minus sign on lign nine to unfold the code.

    kind regards,

    Jos
    I attached a 2nd pic which didn't display in the body of my post for some reason. That 2nd pic shows the code that the error message is covering. You can open it by clicking the Java Error.JPG hyperlink at the bottom of my original post.

    What causes the folding? Why does it occur?

    As I worked on this some more, I ended up getting a different error. I will update my original post.
    Last edited by allDogsAreGood; 09-28-2018 at 12:43 AM.

  4. #4
    Join Date
    Oct 2016
    Posts
    47
    Rep Power
    0

    Default Re: Problem with the main method

    After trying to figure this out some more, the error I got in the picture above on line 9 changed and became: "The method println(Boolean) in the type PrintStream is not applicable for the arguments (void)"

    Eventually I was able to figure out how to resolve this error. The println( ) method expects a value but the method call dog1.showName() has a return type of void, because the body of that method just uses System.out.println( ) to display a method to the console window. So to solve this I simply removed the System.out.println( ) part and just left dog1.showName() and this worked. If you want to see the original code I had, see the pic called "println Error." To see the method definition of the showName( ) method inside of the Dog class, see the pic called "Dog class."

    Just out of curiosity, I would still like to know how to resolve the error I had in my original post about "multiple markers at this line" and "system error on token."
    Attached Thumbnails Attached Thumbnails Problem with the main method-dog-class.png   Problem with the main method-println-error.png  

  5. #5
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,221
    Rep Power
    12

    Default Re: Problem with the main method

    The System.out.println() method is expected to print the argument. But the return of the method showName() is void (i.e. does not return anything to print) so the compiler complains.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

Similar Threads

  1. how to print results from void method into main method?
    By BookOfEliX in forum New To Java
    Replies: 5
    Last Post: 09-20-2015, 10:48 PM
  2. Main method separated from other method
    By Stud1 in forum New To Java
    Replies: 6
    Last Post: 01-13-2014, 04:32 PM
  3. Replies: 4
    Last Post: 03-28-2013, 08:40 PM
  4. Calling The main method from another method
    By SwissR in forum New To Java
    Replies: 3
    Last Post: 07-27-2010, 11:03 AM
  5. calling method from main method
    By bob_bee in forum New To Java
    Replies: 4
    Last Post: 10-02-2009, 05:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •