Android之提示Method return type must not include a type variable or wildcard:
生活随笔
收集整理的這篇文章主要介紹了
Android之提示Method return type must not include a type variable or wildcard:
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1 問題
調(diào)用retrofit的時(shí)候提示錯(cuò)誤如下
Method return type must not include a type variable or wildcard: io.reactivex.Observable<package.class<?>>?
?
?
?
?
?
?
?
2 原因
我們知道英文單詞variable是多變的,易變的意思,然后?wildcard是未知數(shù)的意思,上面的錯(cuò)誤也就是說,這個(gè)函數(shù)返回的類型不能是易變的或者未知數(shù),特么的,這個(gè)函數(shù)是從java代碼轉(zhuǎn)kotlin的
比如java代碼有下面的類,我們需要返回這個(gè)類
public class Test<T> {public int code;public T data; } public Observable<Test> ff() {}轉(zhuǎn)kotlin之后,變成下面了
fun ff(): Observable<Test<*>> {}就是這個(gè)<*>搞出問題來的?
?
?
?
?
?
?
?
3 解決辦法
?把*去掉改成Any
fun ff(): Observable<Test<Any>> {}?
總結(jié)
以上是生活随笔為你收集整理的Android之提示Method return type must not include a type variable or wildcard:的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android之华为平板打日志提示Per
- 下一篇: Andorid之提示java.lang.