July 2017
Beginner to intermediate
715 pages
17h 3m
English
The analysis performed in this application is fairly simple. Once the tweets have been classified as either positive or negative, a total is computed. We used two static variables for this purpose:
private static int numberOfPositiveReviews = 0; private static int numberOfNegativeReviews = 0;
The computeStats method is called from the Java 8 stream and increments the appropriate variable:
public void computeStats() { if(this.category.equalsIgnoreCase("pos")) { numberOfPositiveReviews++; } else { numberOfNegativeReviews++; } }
Two static methods provide access to the number of reviews:
public static int getNumberOfPositiveReviews() { return numberOfPositiveReviews; } public static int getNumberOfNegativeReviews() ...