Results 1 to 2 of 2
  1. #1
    Pojahn_M's Avatar
    Pojahn_M is offline Senior Member
    Join Date
    Mar 2011
    Location
    Sweden
    Posts
    197
    Rep Power
    4

    Default Whats the different between package.class.method and super.method?

    Example:

    Java Code:
    public String toString ()
    {
    	//This is to its super class
    	String obj = super.toString ();
    	return obj;
    }
    Java Code:
    public String toString ()
    {
    	//This is to its super class
    	String obj = packagename.classname.toString ();
    	return obj;
    }
    Do one of these have benefits? Or are the effects exactly the same?

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

    Default Re: Whats the different between package.class.method and super.method?

    The first code simply calls the super's method whatever that is. If the super does not override Object's toString() method, this won't be terribly helpful and will just return the object type and its hashCode. The second returns the class's name.

    The toString() method should be whatever works best for debugging your program.

Similar Threads

  1. problem in set & get method of a super class
    By elenora in forum Advanced Java
    Replies: 5
    Last Post: 04-22-2011, 02:42 PM
  2. Replies: 5
    Last Post: 01-26-2011, 07:38 PM
  3. calling method of different project package class
    By oneofthelions in forum New To Java
    Replies: 3
    Last Post: 02-16-2010, 06:36 PM
  4. how to call higher level super class method?
    By satheeshtech in forum Advanced Java
    Replies: 2
    Last Post: 01-12-2010, 04:11 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
  •