``` private lateinit var movieAdapter: RecyclerVie...
# android
s
Copy code
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
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
Check official docs about generics https://kotlinlang.org/docs/reference/generics.html
👍🏽 2