Results 1 to 2 of 2
  1. #1
    Bgreen7887 is offline Senior Member
    Join Date
    Oct 2010
    Location
    Newark,nj
    Posts
    111
    Rep Power
    0

    Default 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 code
    Java 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);
    		
    		
    
    	 }
    
    
    }

  2. #2
    Bgreen7887 is offline Senior Member
    Join Date
    Oct 2010
    Location
    Newark,nj
    Posts
    111
    Rep Power
    0

Similar Threads

  1. Replies: 0
    Last Post: 02-26-2010, 11:59 AM
  2. Creating your own exception
    By joms999 in forum New To Java
    Replies: 2
    Last Post: 02-17-2010, 05:33 PM
  3. Replies: 1
    Last Post: 01-03-2010, 10:48 PM
  4. Replies: 6
    Last Post: 09-03-2009, 12:40 PM
  5. Replies: 1
    Last Post: 06-23-2008, 06:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •