Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Junky

Thread: why is the top codes wrong??

  1. #1
    lwz123 is offline Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Question why is the top codes wrong??

    1.public Clock (Clock existingClock)
    {
    hours = existingClock.hours;
    isTicking = existingClock.isTicking;
    }

    2.public Clock (Clock newClock)
    {
    hours = newClock.hours;
    isTicking = newClock.isTicking;
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: why is the top codes wrong??

    The two constructors are completely indistinguishable. Why do you think that one is "wrong"?

  3. #3
    Kagiso is offline Member
    Join Date
    Nov 2012
    Location
    Johannesburg, South Africa
    Posts
    92
    Rep Power
    0

    Default Re: why is the top codes wrong??

    Please be warned that I may be wrong as I am new to Java

    what you have written looks like two constructor methods which take the same arguments(of type Clock)... For method overloading this can't be done.
    have you declared the variables (hours & isTicking)?

    perhaps you were trying to say
    hours = existingClock.hours();
    isTicking = existingClock.isTicking(); // which also doesn't make sense

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,779
    Rep Power
    7

    Default Re: why is the top codes wrong??

    Quote Originally Posted by Kagiso View Post
    two constructor methods
    There are constructors and there are methods. No such thing as a constructor method.
    DarrylBurke likes this.

Similar Threads

  1. Help with these two codes
    By blackdiz in forum New To Java
    Replies: 5
    Last Post: 06-09-2012, 12:03 PM
  2. JSP update what's wrong with the following codes?
    By Kareng in forum New To Java
    Replies: 9
    Last Post: 06-23-2011, 05:44 PM
  3. I need some codes
    By johnmergene in forum New To Java
    Replies: 11
    Last Post: 01-25-2011, 03:42 AM
  4. What do the following codes do?
    By javaguy2 in forum New To Java
    Replies: 2
    Last Post: 01-23-2011, 10:23 PM
  5. What's wrong with my codes?
    By ayoood in forum New To Java
    Replies: 16
    Last Post: 09-01-2008, 03:57 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
  •