Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The attached class and its tester abort. You should analyze the situation and provide the following information: provide a screenshot using the debugger of Eclipse

The attached class and its tester abort. You should analyze the situation and provide the following information:

provide a screenshot using the debugger of Eclipse showing all appropriate local and instance variables JUST BEFORE THE EXCEPTION.

identify the error, and how to fix it.

This assignment requires no programming on your part, and you are not expected to submit any code. Just prove that you know exactly when the problem occurs, and how you would fix it.

import java.util.ArrayList;

public class Kaboom {

public static void main(String[] args) { String[] strs = { "aardvark", "show", "flower", "mantle", "table", "clock", "red", "show", "water" }; StrCharCounter k = new StrCharCounter(); for (String s: strs) { k.add(s); } System.out.println("length of all strings " + k.calcTotalLength()); }

}

...........................................................................................................

import java.util.ArrayList;

/** * This class keeps a set of unique strings, and lets the user * ask the total length of all Strings in the store. * * @author parks * */ public class StrCharCounter {

private ArrayList store = new ArrayList<>(); private int size = 0;

public boolean add(String sToAdd) { size++; if (!store.contains(sToAdd)) return store.add(sToAdd); else return false; }

public int calcTotalLength() { int cnt = 0; for (int i = 0; i < size; i++) { cnt += store.get(i).length(); } return cnt; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 10g Insider Solutions

Authors: Arun R. Kumar, John Kanagaraj, Richard Stroupe

1st Edition

0672327910, 978-0672327919

More Books

Students also viewed these Databases questions

Question

8. Demonstrate aspects of assessing group performance

Answered: 1 week ago