質問

I'm following this tutorial for twitter4j:

http://www.javacodegeeks.com/2011/10/java-twitter-client-with-twitter4j.html

and I've gotten almost everything right. All my code compiles except for this one little part:

 ResponseList list = twitter.getHomeTimeline();
    for (Status each : list) { //incompatible types error

        System.out.println("Sent by: @" + each.getUser().getScreenName()
                + " - " + each.getUser().getName() + "\n" + each.getText()
                + "\n");
    }

This is the output for that exception: incompatible types found : java.lang.Object required: twitter4j.Status

I'm using the twitter4j 2.2.5 jars. What am I doing wrong???

役に立ちましたか?

解決

Generics is missing, maybe you could try:

    ResponseList<Status> list = twitter.getHomeTimeline();
    for (Status each : list) {

        System.out.println("Sent by: @" + each.getUser().getScreenName() + " - " + each.getUser().getName() + "\n"
                + each.getText() + "\n");
    }
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top