The purpose of this is confusing. Who exactly checks what the interface implementation has been typed to? Since the compiler checks anyway what the method accepts.
If play accepts Instrument args, it will fit Instrument and if will fit Guitar, so you can send polymorphic objects as arguments to it. It will not fit Object, so the play method implementation can safely work on Instruments it receives. Even if the whole class 'Implements Player' (with no generics), right?
I know the purpose of typing Collections is because otherwise there is no other mechanism to limit the type of things Collection can contain. But method declarations have this mechanism anyway.
About Question com.enthuware.ets.scjp.v6.2.94 :
Moderator: admin
-
- Posts: 27
- Joined: Mon Sep 22, 2014 1:30 pm
- Contact:
-
- Site Admin
- Posts: 10388
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.94 :
All generics related information is checked (and then stripped off) by the compiler. Runtime has no knowledge of generics.
Who is online
Users browsing this forum: No registered users and 6 guests