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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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