July 2018
Intermediate to advanced
400 pages
12h 14m
English
Add another method to Jhava called determineFriendshipLevel. determineFriendshipLevel should return a value of type String and, because the monster does not understand friendship, a value of null.
Listing 20.4 Returning null from a Java method (Jhava.java)
public class Jhava {
public String utterGreeting() {
return "BLARGH";
}
public String determineFriendshipLevel() {
return null;
}
}
Call this new method from Hero.kt, storing the monster’s friendship level in a val.
You are going to print this value out to the console, but, remembering that the monster yelled its greeting at you in all caps, go ahead and lowercase the friendship level before printing it out.
Listing 20.5 Printing the friendship ...