Write a custom java exception class named badarrayexception

Assignment Help JAVA Programming
Reference no: EM13940767

Write a custom Java exception class named BadArrayException that has two constructors:

- A default constructor with no arguments.

- A constructor taking a String parameter (the exception message) that must be passed to the parent Exception(String) constructor.

Write a Java class named ArrayUtils that contains the following public methods. The class must implement all the search and copy logic for these methods. It can not use array methods from the Java API.

1. public static int minValue(int[] list)

This static method searches its parameter array to locate the minimum value, and returns it. Do not use sorting to find the minimum value in the array. The array may contain any negative, 0, and/or positive values. If the array parameter is length 0, it must throw a BadArrayException with the message "Array is empty".

2. public static int[] copyRange(int[] list, int startIndex)

This static method copies the specified range of elements from the parameter array into a new array, and returns it. The initial index of the range (startIndex) must lie between 0 and list.length, inclusive. The range is [startIndex, Index of last element in the list]. If the startIndex parameter is less than 0 or greater than list.length, it must throw an ArrayIndexOutOfBounds exception with startIndex as the exception object parameter.

3. public static int indexOf(int[] list, int searchValue)

This static method searches its parameter array to locate the first occurrence of the parameter searchValue, and returns its index position if found, or -1 if not found. If the array parameter is length 0, it must return -1.

4. public static int lastIndexOf(int[] list, int searchValue)

This static method searches its parameter array to locate the last occurrence of the parameter searchValue, and returns its index position if found, or -1 if not found. If the array parameter is length 0, it must return -1.

If the array parameter is null, methods must throw a BadArrayException with the message "Array is null". These methods should not catch the BadArrayException they throw due to a null or empty array parameter. The exception is thrown back to the calling code to handle.

Test the implementation of BadArrayException and ArrayUtils classes with the help of attached ArrayUtilsDemo class.

Attachment:- ArrayUtilsDemo.txt

Reference no: EM13940767

Questions Cloud

Calculate the maximum speed in km : Show that the car is likely to skid rather than overturn if the speed is excessive and calculate the maximum speed in km h 1 at which it can travel round the curve. What will be the reactions of the inner and outer wheels at this speed?
To what extent does leadership influence the market : To what extent does leadership influence the market performance of companies?
Travelled the city selling carpets : Lou Krantz started his carpet business Regal Carpets in Oakland, California in 1995 with a brainwave idea, "Why do customers need to travel to out of town stores in order to buy their carpets - why doesn't the store come to them" he thought. So hi..
What is abercrombie and fitchs receivables turnover : Using the balances reported on the balance sheets, what is Abercrombie & Fitch's receivables turnover for the year ended February 3, 2007?
Write a custom java exception class named badarrayexception : A constructor taking a String parameter (the exception message) that must be passed to the parent Exception(String) constructor.
Describe each team member personality type : Write a 350- to 700-word paper in which includes the following: Describe each team member's personality type Describe the advantages of working with those with differing personality types
What is the maximum speed at which a car can travel : What is minimum radius of level curve that the wagon can negotiate at this speed without overturning?
Passive and active investment management strategies : Explain how unpredictable market conditions and economies play a role in passive and active investment management strategies.
Firm current business strategy based on outcomes : Evaluate the suitability of the firm's current business strategy based on the outcomes of your analysis (e.g., the identification of the firm's current strategy and the most significant factors affecting the firm's performance,

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a java program using array to auto-grade exams

Write a JAVA program using 2D Array to auto-grade exams. For a class of N students, your program should read letter answers (A, B, C, D) for each student.

  What is the greatest common divisor

What is the greatest common divisor of the Fibonacci numbers f100 and f101 by Euclid algorithm.

  Implement a class quiz

Implement a class Quiz that implements the Measurable interface.

  Implement a recursive method that evaluates the gcd

Implement a recursive method that evaluates the GCD of the given numbers - Use the above fact to create a recursive method in Java that computes and returns the gcd of two positive integers. Comment the code.

  In this project you need to write a program called

in this project you need to write a program called ecc.javato implement elliptic curve

  Determines and displays the smallest and largest

Create a method that determines and displays the smallest and largest of the ten values. Then, pass the array to the method - Create a GUI application whose button's Click() method accepts ten integer values from a TextBox and stores them in an arra..

  Modify the java application using java netbeans ide

Modify the Java application using Java NetBeans IDE to meet these additional and changed business requirements. The application will now compare the total annual compensation of at least two salespersons.

  Program should assign a seat in the first class

If a person enters 1, your program should assign a seat in the first class (rows 1 - 3). If a person enters 2, your program should assign a seat in business class (rows 4 - 7). If a person enters 3, your program should assign a seat in economy class ..

  1 write an application class that contains several

1 write an application class that contains several methods.nbspthe first method should be named greeting and should

  Explain eventhandling concepts in java

Enhance the ButtonViewer program so that it prints the time at which the button was clicked.Please provide the ClickListener class in your solution.

  Implement a distributed banking application

In the first part, you will implement a distributed banking application. The distributed bank has multiple branches. Every branch knows about all other branches.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd