+ 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?

16th Nov 2018, 4:48 AM
Nikki Singh
Nikki Singh - avatar
7 odpowiedzi
+ 1
Ohh my god! I was guessed that about this keyword😁😁😁😁
17th Nov 2018, 7:29 PM
Bipin Tatkare
Bipin Tatkare - avatar
+ 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. 😉
16th Nov 2018, 8:21 AM
Zephyr Koo
Zephyr Koo - avatar
+ 3
thanks bro
16th Nov 2018, 9:03 AM
Nikki Singh
Nikki Singh - avatar
+ 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().
17th Nov 2018, 7:28 PM
Bipin Tatkare
Bipin Tatkare - avatar
+ 2
Nikki Singh sorry for inconvinience.
17th Nov 2018, 7:30 PM
Bipin Tatkare
Bipin Tatkare - avatar
+ 1
this helped me so much Bipin tatkare I will find out my problem and fix it.
20th Nov 2018, 10:38 AM
Nikki Singh
Nikki Singh - avatar
0
Nikki Singh You're welcome! 😄
16th Nov 2018, 12:52 PM
Zephyr Koo
Zephyr Koo - avatar