I am using last.fm API from here http://code.google.com/p/lastfm-java/
I downloaded it to my workspace, checked it as library, and imported it to my project... The problem comes when I try to use one method of the API
Artist[] artist = LastFmServer.searchForArtist("hatebreed");
I dont know why, it says
Cannot make a static reference to the non-static method searchForArtist(String) from the type LastFmServer
But I have another error trying to solve it. It causes this line
String artist = Artist.getName();
Cannot make a static reference to the non-static method getName() from the type Artist
its my first time using APIs, and i started getting tired of these errors, please help
Like other said you need to Instantiate
LastFmServer
like
LastFmServer mLastFmServer= new LastFmServer();
and then called you method like
Artist[] artist = mLastFmServer.searchForArtist("hatebreed");
您必须使用new
(或适当的工厂方法)实例化LastFmServer
和Artist
。
您需要使用new
实例化 LastFmServer和Artist的相应对象。
LastFmServer lastFmServerObj = new LastFmServer();
You have to call the methods through a object and not make a static reference.
I'm guessing you'd create an LastFmServer
like so (depending on the constructor).
LastFmServer object = new LastFmServer();
I hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.