Twitter4j IDs to Array

I am attempting to compare two lists. One list contains everyone I am following on twitter, the other is everyone who follows me. I don’t know how to do this since .getFollowersIDs and .getFriendsIDs are of type ID. I have looked this up, but I can’t understand how to compare the results of this type. I tried treating it like they both were arrays, but Eclipse didn’t like that..

The type of the expression must be an array type but it resolved to IDs

package com.follow3d.rob;

import java.util.List;
import twitter4j.*;
import twitter4j.conf.*;

public class Follow3d {

    public static void main(String[] args) {

        ConfigurationBuilder cb = new ConfigurationBuilder();
        TwitterFactory tf = new TwitterFactory(;
        Twitter twitter = tf.getInstance();
        try {
                long ID = twitter.getId();//Personal Twitter ID.
                IDs FOLLOWERS = twitter.getFollowersIDs(-1);//Numeric Array of every user that follows me. 
                IDs FOLLOWING = twitter.getFriendsIDs(-1);//Numeric Array of every user I am following. 
                while (FOLLOWING.hasNext() == true)
                    int counter = 0;
                    if (FOLLOWING[counter] != FOLLOWERS[counter])//ERROR HERE.
            } catch (TwitterException name) {
                System.out.println("You don't have internet connection.");


As explained in the documentation, FOLLOWERS and FOLLOWING are of type IDs (not array) and hence, we can’t reference any element inside it by index.

If we need to compare the followers and following user ids then, we need to use getIDs() method of IDs class (i.e. FOLLOWERS and FOLLOWING objects) and iterate through them. Also, instead of iterating using while loop (as shown in the example), we need to iterate FOLLOWING array for each element of FOLLOWERS array to see if an id exists or not.

Leave a Reply

Your email address will not be published. Required fields are marked *