View Single Post
  #3 (permalink)  
Old 04-10-2008, 06:48 AM
CaptainMorgan's Avatar
CaptainMorgan CaptainMorgan is offline
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Hi steve. All you need to do is:
Code:
public class StringTooLongException extends Exception { public StringTooLongException(String message) { throw new IllegalArgumentException("Exception: String too long."); } }
With this, the output is below on an input of "Hello":
Quote:
Hello
Hello
But on input longer than 32 you see this:
Quote:
123456789012345678901234567890123
Exception in thread "main" java.lang.IllegalArgumentException: Exception: String too long.
at StringTooLongException.<init>(StringTooLongExcepti on.java:4)
at TooLongCrashes.main(TooLongCrashes.java:17)
Java Result: 1
Should this satisfy your question, please mark this thread as 'Solved', if not, definitely let us assist with more on this topic.

My bad.. I didn't see that it actually worked before I made an adjustment.. so, basically you picked up another way to throw an exception.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)

Last edited by CaptainMorgan : 04-10-2008 at 06:51 AM.
Reply With Quote