Linked Questions

1 vote
1 answer
3k views

I need to change the return message of the method getMessage() , for instance, i have an ArithmeticException, and when I write: try{c=a/0;} catch(ArithmeticException excep){System.out.println( excep....
Amine's user avatar
  • 19
0 votes
0 answers
56 views

I am trying to write a custom exception class for a program that connects to a local MySQL database and throws an exception if we are unable to connect (bad database, username, or password). However ...
Ryan's user avatar
  • 262
191 votes
7 answers
114k views

Isn't this one automatically put by the compiler if I don't put it in a subclass's constructor? That means I don't even need to care about it? In some articles they put it out. And if I've got one ...
ajsie's user avatar
  • 80.1k
6 votes
2 answers
5k views

I have a small Scala program which reads data from a data source. This data source is currently a .csv file, so it can contain data inconsistencies. When implementing a repository pattern for my ...
rumtscho's user avatar
  • 2,524
3 votes
3 answers
17k views

I have a menu which reads integers for input ,here is the method for the menu: public int menu(String _menuHeader,String[] _menuItems) throws InvalidInputException { int choice = 0; do { ...
Snedden27's user avatar
  • 1,928
1 vote
3 answers
12k views

For homework, I have to develop an exceptions code: "Use inheritance to create a superclass of exception called ExceptionA, and two subclasses of the exception called ExceptionB and ExceptionC, where ...
OHHH's user avatar
  • 1,061
1 vote
4 answers
3k views

I have a method that should only accept strings of a certain format. When the format is invalid, I want to throw an Exception. I'm quite new to Java, so am not sure what the correct type of exception ...
Jeroen De Dauw's user avatar
2 votes
4 answers
2k views

So I've been working with Java for a little while now. I technically am still new to the language. I have created a couple custom errors for a personal project I'm working on and I was wondering if ...
Spedwards's user avatar
  • 4,510
9 votes
4 answers
206 views

Is it good to have a class with short methods used to catch Exceptions? class ContractUtils{ public static String getCode(Contract contract) throws MyException{ try{ return contract....
raythurnevoid's user avatar
2 votes
5 answers
874 views

I have the following method to implement for an ArrayList, but I'm not sure how to go about treating the exception. If the ArrayList is empty does it automatically throw that exception or do I need to ...
gemart's user avatar
  • 376
0 votes
2 answers
2k views

I want to try and catch in java, when I wrote the catch part it asked me for a parameter, the parameter I want to use is ValueError (as meaning in python) Example: try { System.out.print("...
ronald7894's user avatar
0 votes
2 answers
3k views

I am building a web application i ve a login jsp form which will be redirected to a servlet... My servlet code: Login login=new Login(); login.setUserName(request.getParameter("txtUsername"))...
user3222718's user avatar
0 votes
5 answers
2k views

Create a new exception class IllegalDimensionException that extends Exception class. It will have two constructors, one default- value and one explicit value that uses the message "Illegal dimension ...
Chaz32621's user avatar
  • 127
0 votes
3 answers
149 views

Exception Handling: Direct quote from a professor, "Although the Exception class can be used directly in a program, it is better to use a specific exception class." He did not extend much on it but ...
Mariela's user avatar
  • 19
1 vote
2 answers
626 views

Program to raise an exception stating "Further Transactions Not Possible until clearance of bill." when a customer's unpaid credit card amount cross $2000 or is unpaid upto 45 days. Assume that the ...
user-6589801's user avatar

15 30 50 per page