Results 1 to 2 of 2
Thread: Creating Exception class
- 12-09-2010, 08:08 PM #1
Senior Member
- Join Date
- Oct 2010
- Location
- Newark,nj
- Posts
- 111
- Rep Power
- 0
Creating Exception class
Hey guys can anyone figure out why im getting a numberformatexception...
NOOB PROGRAM..trying to get users to enter strings until they enter done.if that string has more than say 25 characters throw my exception..heres the codeJava Code:import java.util.*; public class StringDriver { public static void main(String[] args) throws StringToLongException{ Scanner read = new Scanner(System.in); String me = "done"; final int MIN =1; final int MAX =25; System.out.println("Please enter couple sentences"); String input = read.nextLine(); int change = Integer.parseInt(input); StringToLongException trouble = new StringToLongException("USE LESS CHARS/ STRING!!"); while(!input.equals(me)){ System.out.println("Please enter couple sentences"); input = read.nextLine(); if(input == me){} if (change > MAX) throw trouble; } } } **************************** public class StringToLongException extends Exception { String input; public StringToLongException(String msg) { super (msg); } }
- 12-09-2010, 08:18 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Newark,nj
- Posts
- 111
- Rep Power
- 0
Similar Threads
-
Null pointer exception while creating stubs from WSDL
By MarKco in forum NetworkingReplies: 0Last Post: 02-26-2010, 10:59 AM -
Creating your own exception
By joms999 in forum New To JavaReplies: 2Last Post: 02-17-2010, 04:33 PM -
Exception Class for class that compares objects variables. Help Please.
By darkblue24 in forum New To JavaReplies: 1Last Post: 01-03-2010, 09:48 PM -
Null pointer exception when creating image button!
By iansu in forum AWT / SwingReplies: 6Last Post: 09-03-2009, 11:40 AM -
Null pointer exception after creating RCP plugin
By bhanu in forum EclipseReplies: 1Last Post: 06-23-2008, 05:27 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks