Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/BruceEckel/OnJava8-Examples
/ main
Method
main
staticchecking/petspeak/PetSpeak.java:27–31 ·
view source on GitHub ↗
(String[] args)
Source
from the content-addressed store, hash-verified
25
public
class
PetSpeak {
26
static
void
command(Pet p) { p.speak(); }
27
public
static
void
main(String[] args) {
28
Pet[] pets = {
new
Cat(),
new
Dog() };
29
for
(Pet pet : pets)
30
command(pet);
31
}
32
}
33
/* Output:
34
meow!
Callers
nothing calls this directly
Calls
1
command
Method · 0.95
Tested by
no test coverage detected