https://kotlinlang.org logo
Title
s

Sudhir Singh Khanger

05/02/2018, 7:40 AM
private lateinit var movieAdapter: RecyclerView.Adapter<*>
private lateinit var movieAdapter: MovieAdapter
What is the difference between declaring type as the exact class of name
MovieAdapter
and
RecyclerView.Adapter<*>
? Also what does it mean by the asterix
<*>
? Which one is better?
e

edwardwongtl

05/02/2018, 8:10 AM
If you declare as
RecyclerView.Adapter
, then any subtype of
RecyclerView.Adapter
can be assign to
movieAdapter
. Declaring as
MovieAdapter
means you can only assign subtype of
MovieAdapter
into it. The
<*>
basically means any type.
👍🏽 1
g

gildor

05/02/2018, 10:13 AM
Check official docs about generics https://kotlinlang.org/docs/reference/generics.html
👍🏽 2