Results 1 to 11 of 11
  1. #1
    infernocy is offline Member
    Join Date
    Apr 2012
    Posts
    15
    Rep Power
    0

    Default overidding version of toString

    How to overwrite a toString method
    Last edited by infernocy; 04-12-2012 at 09:09 PM. Reason: some changes

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: overidding version of toString

    Quote Originally Posted by infernocy View Post
    when i click on the inherited methods of the subclass and click toString method of the abstract class ...
    How on earth do you click on a method?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default Re: overidding version of toString

    Can you make a small simple example showing the problem and post it?
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default Re: overidding version of toString

    Quote Originally Posted by DarrylBurke View Post
    How on earth do you click on a method?

    db
    That is one of the secrets of the malicious mouse masters! <diabolical laughter/> The malodorous mad mouse mogul can even click on ... <drum roll> string literals! <diabolical laughter again/>

    May the cheese be with you.

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,611
    Rep Power
    25

    Default Re: overidding version of toString

    That's one of the Dutch problems. Too much cheese. Goes to their brains and makes cheese of it.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,679
    Blog Entries
    7
    Rep Power
    21

    Default Re: overidding version of toString

    Quote Originally Posted by Norm View Post
    That's one of the Dutch problems. Too much cheese. Goes to their brains and makes cheese of it.
    You obviously haven't met his wife; she has even more power than he has; she is misses mightier malodorous mad mouse mogul.

    kind regards,

    Jos ;-)
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    jim829 is online now Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,804
    Rep Power
    5

    Default Re: overidding version of toString

    Quote Originally Posted by RohanChaubey View Post
    I knew methods can be overridden but I didn't knew that predifined mathods can also be overridden ?
    By predefined, do you mean methods that have already been implemented? How could you override something that doesn't
    exist? Note: abstract method signatures don't exist so they aren't overridden but implemented.

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

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is online now Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,000
    Rep Power
    10

    Default Re: overidding version of toString

    Note: This thread is over 2 years old...
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,149
    Rep Power
    6

    Default Re: overidding version of toString

    Quote Originally Posted by RohanChaubey View Post
    I knew methods can be overridden but I didn't knew that predifined mathods can also be overridden ?
    Well why not? What's so special about methods/classes that just happen to already exist?

    Assuming that "predefined method" means a method of a standard JDK class, for example Object.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,149
    Rep Power
    6

    Default Re: overidding version of toString

    Quote Originally Posted by RohanChaubey View Post
    So, gimbal can we override methods like toString and rest of the methods which are available in JDK ?
    I suggest you try it and find out.

    You can already know without asking. Methods like toString(), equals() and hashCode() basically exist to be overridden.

    There is however the final keyword. If you haven't read about it, you might want to do that at this point.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  11. #11
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: overidding version of toString

    Too bad #6 in this thread wasn't marked as final

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. toString
    By Waarten in forum New To Java
    Replies: 11
    Last Post: 01-25-2012, 04:02 PM
  2. toString
    By juanvalentinequintana in forum New To Java
    Replies: 2
    Last Post: 05-13-2011, 05:30 PM
  3. help with toString
    By teardrop3903 in forum New To Java
    Replies: 5
    Last Post: 04-28-2011, 03:39 AM
  4. java -version pointing to older version
    By deepakts in forum New To Java
    Replies: 4
    Last Post: 05-06-2010, 10:59 AM
  5. Can i just use toString?
    By cachi in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 09:32 PM

Posting Permissions

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