I'm using Twitter4j lib and made the code without setup() and draw()

The piece of code is used to print my first tweet from a selection of first eight tweets from my time line. I'm using Twitter4j lib and made the code without setup() and draw(). But now when I'm trying to put it in setup and draw(so that I can do something useful with that data), at one line(statuses..........something), it shows an error. I'm not able to put it in proper structure. Can any body help me here to put it in setup(), draw() etc. properly?

Thanks in advance

here's the code

import twitter4j.conf.*;
import twitter4j.internal.async.*;
import twitter4j.internal.org.json.*;
import twitter4j.internal.logging.*;
import twitter4j.json.*;
import twitter4j.internal.util.*;
import twitter4j.management.*;
import twitter4j.auth.*;
import twitter4j.api.*;
import twitter4j.util.*;
import twitter4j.internal.http.*;
import twitter4j.*;
import twitter4j.internal.json.*;

ConfigurationBuilder cb = new ConfigurationBuilder();


java.util.List statuses = null;

Twitter twitter = new TwitterFactory(cb.build()).getInstance();

String userName ="dattasaurabh82";
int numTweets = 100;
String[] twArray = new String[numTweets];

try {

  Paging page = new Paging (1, 8);//page number, number per page
  statuses = twitter.getUserTimeline(userName, page);

 // statuses = twitter.getUserTimeline(userName);
catch(TwitterException e) {

for (int i=0; i<statuses.size(); i++) {
  Status status = (Status)statuses.get(i);

  //println(status.getUser().getName() + ": " + status.getText());
  twArray[i] = status.getUser().getName() + ": " + status.getText();

String latestUpdate = twArray[0];


Sign In or Register to comment.