• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

return super.getC(); equals to return this.getC();

 
Folkert Meeuw
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The syntax for calling a superclass constructor is

super();
--or--
super(parameter list);

With super(), the superclass no-argument constructor is called. With super(parameter list), the superclass constructor with a matching parameter list is called.


Is super. in this case the equal use like this. ?


 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this. refers to current object, ....super. refers to superclass variables or .....
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in this case the equal use like this. ?


I am not sure I understood that correctly. Can you elaborate on your question a little more ?
 
Folkert Meeuw
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak Bala wrote:
in this case the equal use like this. ?


I am not sure I understood that correctly. Can you elaborate on your question a little more ?


Hello Deepak Bala:

What I know is:


What I didn't know 'til yet is:
 
Kedar Sarmalkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folkert Meeuw wrote:

The syntax for calling a superclass constructor is

super();
--or--
super(parameter list);

With super(), the superclass no-argument constructor is called. With super(parameter list), the superclass constructor with a matching parameter list is called.


Is super. in this case the equal use like this. ?





First thing... the code that you have randomly put here.... did you ever try it on your own.... it has infinite errors..... the super.d won't work as d is private in A, and is there any new style of writing methods where in they return in the argument list itself which I'm nor aware of ? in your case public int getD(return d);

ok mistakes apart.... this can be used for calling methods,constructor or to refer members of own class..... while super can be used for calling methods,constructor or to refer members of parent class of course if they are visible to child class.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folkert, can you indent your code please.


Which code do you think looks better and is more readable. If a person is not able to read your code, how is him/her supposed to help you??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic