Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Constructors Trouble

    Hi,

    I followed this tutorial and I have no idea what Im doing.

    I have got this code : [Java] //line 8, 11, 14 are erroring in eClipse. Can you figure out why? private int - Pastebin.com And line 8, 11 adn 14 are erroring. I have no idea why that is. Can you guys maybe explain me what he is doing here and resolve my code?

    Thank you,

    LearninTOprogram

  2. #2
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    317
    Rep Power
    4

    Default Re: Constructors Trouble

    Hi, welcome to the forums.

    Constructors do not require a return type. For example, the error on line 8 is actually being caused by an error on line 6 which should read as follows.
    Java Code:
    public newClass(){ // note the missing return type.
    Regards.

  3. #3
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Re: Constructors Trouble

    Quote Originally Posted by Ronin View Post
    Hi, welcome to the forums.

    Constructors do not require a return type. For example, the error on line 8 is actually being caused by an error on line 6 which should read as follows.
    Java Code:
    public newClass(){ // note the missing return type.
    Regards.
    Thanks for the response, I have changed it to this and is it correct? public class secondClass { private int hour; private int minute; private i - Pastebin.com

    At this point the 'this' command is giving me errors. It gives me the error in eClipse: Constructor call must be first statement in a constructor. I am not quite sure what to do.

    Thanks

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: Constructors Trouble

    When asking for help on a forum, post the code, properly wrapped with code tags*

    Don't expect members here to click external links just to see what you're doing wrong.

    db

    * Guide For New Members
    BB Code List - Java Programming Forum - Learn Java Programming
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    Ronin is offline Senior Member
    Join Date
    Oct 2010
    Posts
    317
    Rep Power
    4

    Default Re: Constructors Trouble

    There is still a constructor on line 15 which uses the 'void' keyword which needs removing.

    Instead of calling this(), call the setTime() method.

    Regards.

Similar Threads

  1. Help with constructors
    By Modulus in forum New To Java
    Replies: 2
    Last Post: 02-11-2013, 01:12 AM
  2. Constructors
    By cups in forum New To Java
    Replies: 1
    Last Post: 02-15-2012, 11:55 AM
  3. Constructors
    By EdOBannon in forum Advanced Java
    Replies: 2
    Last Post: 12-15-2011, 11:05 AM
  4. constructors?
    By shroomiin in forum New To Java
    Replies: 4
    Last Post: 10-13-2009, 02:14 PM
  5. Help with constructors
    By Minime in forum New To Java
    Replies: 3
    Last Post: 04-09-2008, 07:59 AM

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
  •