what happened in the foreach loop mean how at the place of cat object address how uppercase String will print
Can any one explain how toString method call ?
can any one please explain
Resolved
Comments (6)
- Popular
- New
- Old
You must be signed in to leave a comment
Shaik Azharuddin
15 July 2020, 10:52
how the tostring method is called unless we are using object.method operation
0
Skynet
28 March 2020, 14:37
Where is the code?
Delete this question and create a new one with the code attached. Otherwise, we cannot see what you've done so far.
0
Ashish RajAnand
29 March 2020, 01:49
0
Skynet
29 March 2020, 13:30
Don't quite get your question about the for each loop, sorry. The code above doesn't pass verification?
Are you asking about the syntax in the toString() method and what it means?
0
Ashish RajAnand
29 March 2020, 13:42
Sorry to say i passed verification.
My question is how in for loop
System.out.println(pair.getKey() + " - " + pair.getValue());
how will print the Cat object because here we define Map<String,Cat>
Cat is object and how object will return by using toString method
0
Seb
29 March 2020, 14:35solution
pair.getValule() calls the cat object - and when you print out the cat object in this context, it will use the toString method of the Cat class, and thus print out the cat's name in upper case letters.
System.out.println(cat) and System.out.println(cat.toString()) have the same effect.
+2