+ 6
How this is working? In java
TreeMap t=new TreeMap(); t.put("5","6"); t.put("7","9"); SortedMap s=t.getKeys(); how sorted map can take return value while it's an interface..why explain someone?
7 Réponses
+ 1
Ohh my god! I was guessed that about this keyword😁😁😁😁
+ 6
Congratulation as you just found out an example of polymorphism!
Interface was used to define the intended behaviour so there's nothing wrong here as the underlying object is a valid instance of class. 😉
+ 3
thanks bro
+ 2
this, it is used to declare a variable which is also declared in the function arguments. From this keyword, we can declare the fixed value of a variable which is inside in method and with similar name.
For eg.
void add(int a, int b) {
this.a = a;
this.b = b;
}
In above example, value which passed from arguments, declare values to the variable a and b inside the method add().
+ 2
Nikki Singh sorry for inconvinience.
+ 1
this helped me so much Bipin tatkare I will find out my problem and fix it.
0
Nikki Singh You're welcome! 😄