Class 2 | Intermediate Java 30-IT-397 |
Making Your Own Exception Classes
/*
* ListNotLongEnough.java
*
* Created on April 1, 2002, 9:15 PM
*/
/**
*
* @author jonesbr@email.uc.edu
*/
public class ListNotLongEnoughException extends java.lang.Exception
{
// Number of items in the list.
int numberOfItems;
/**
* Creates a new instance of <code>ListNotLongEnough</code>
without detail message.
*/
public ListNotLongEnoughException() {
}
/**
* Constructs an instance of <code>ListNotLongEnough</code>
with the specified detail message.
* @param msg the detail message.
*/
public ListNotLongEnoughException(String msg)
{
super(msg);
}
/**
* setNumberOfItems
* Sets the number of items in the list.
*
* @param numberOfItems the number of items
in the list.
*
*/
public void setNumberOfItems(int numberOfItems)
{
this.numberOfItems =
numberOfItems;
}
/**
* getNumberOfItems
* Gets the number of items in the list.
*
* @return the number of items.
*/
public int getNumberOfItems() {
return numberOfItems;
}
}
Created by: Brandan Jones December 17, 2001