If tweetType < 0 || tweetType > 2 then
default:
break;
is reached which does not assign a value to messages.
You need to assign a value in the default branch, or throw an exception, or return so that the array is initialized at first use.
Perhaps change that to
default:
throw new IllegalArgumentException("Invalid tweet type : " + tweetType);
or ideally change tweetType to be an enum so that you can cover all cases exhaustively.
enum TweetType {
MENTIONS,
DIRECT_MESSAGES,
ALL_MESSAGES,
;
}
and change int tweetType to TweetType tweetType.