Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help with my final review? (intro to java) 5. (20 points) Labels and loops. What

ID: 657904 • Letter: H

Question

Help with my final review? (intro to java)

5. (20 points) Labels and loops. What does the following method calculate and return?

public int[] loopy(JLabel[][] labels) { final int MAX_LABEL_LENGTH = 100; int[] nums = new int[MAX_LABEL_LENGTH]; for (int i = 0; i < labels.length; i++) { for (int j = 0; j < labels[i].length; j++) { nums[labels[i][j].getText().length()]++; } } return nums; }

---- doesn't it just return a bunch of null statements...? haha

6. (30 points) Writing Classes. Write a class to represent a Twitter account. An account has a String id, an email address and a list of all hashtags (use an ArrayList) used by this account

. a. Write a class skeleton with appropriate variable declarations.

b. Write a constructor that creates an account using the specified id and email address. The list of hashtags is initialized to be empty.

c. Write a method named checkHashtag(String tag) that returns true if the given tag was ever used by the account, false otherwise. Use the contains(Object o) method from the ArrayList class to do the search.

Explanation / Answer


nums is an array which contains THE LENGTH of each label in every label row.

public class twitter_accnt
{
private String id;
private String email_address;
private ArrayList<String> hashtag;
twitter_accnt(String i,String e)
{
id=i;
email_address=e;
ArrayList<String> hashtag=new ArrayList<String>();
}
Boolean checkHashtag(String tag)
{
if(hashtag.contains(tag))
return true;
else
return false;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote