Java Reference
In-Depth Information
private
private void
void indexException ( int
int index ) {
throw
throw new
new IllegalArgumentException ( index +
" doesn't correspond to an Artist" );
}
public
public String getArtistName ( int
int index ) {
try
try {
Artist artist = getArtist ( index );
return
return artist . getName ();
} catch
catch ( IllegalArgumentException e ) {
return
return "unknown" ;
}
}
}
Open Exercises
1. Look through your work code base or an open source project you're familiar with and
try to identify classes that have just static methods that could be moved to static meth-
ods on interfaces. It might be worth discussing with your colleagues whether they
agree or disagree with you.
Search WWH ::




Custom Search