March 2019
Intermediate to advanced
242 pages
6h 21m
English
As a Java developer, you should have worked with code such as the one highlighted in bold in the following block:
Object obj = new Ocean(); // variable type - Object if (obj instanceof Ocean) { // check instance type
System.out.println(((Ocean)obj).getBottles()); // cast & extract value
}
// A basic class - Ocean
class Ocean {
private long bottles;
public long getBottles() {
return bottles;
}
}
The preceding code includes three steps to use the value of the bottles variable:
Read now
Unlock full access