Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-09-2007, 08:24 PM
Senior Member
 
Join Date: Nov 2007
Posts: 111
bugger is on a distinguished road
throwing Exception
I want to throw exception manually. I tried the following but it fails.
Code:
throw java.lang.ArrayIndexOutOfBoundsException;
I get following exception:
Code:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: java.lang.ArrayIndexOutOfBoundsException cannot be resolved
Please advice.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-09-2007, 09:50 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 123
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
What does your method signature look like?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-09-2007, 11:21 PM
Senior Member
 
Join Date: Nov 2007
Posts: 111
bugger is on a distinguished road
Code:
public void calculateSum() { ... }
Actually method has nothing to do with this. I want to know, can I raise an exception myself?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-09-2007, 11:35 PM
ShoeNinja's Avatar
Senior Member
 
Join Date: Oct 2007
Posts: 123
ShoeNinja is on a distinguished road
Send a message via AIM to ShoeNinja
Yes. You just have to put 'throws whateverException' on the end of your signature.

Code:
public void calculateSum() throws InvalidSumException{ }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
exception Oktam New To Java 2 03-23-2008 09:01 PM
Trouble with factory method - unhandled exception type Exception desmond5 New To Java 1 03-08-2008 08:41 PM
Main method throwing specific Exception bugger New To Java 3 01-22-2008 05:08 AM
Exception Camden New To Java 2 11-27-2007 01:50 AM
Which statement is throwing a runtime error.... money123 New To Java 1 07-30-2007 02:55 PM


All times are GMT +3. The time now is 10:34 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org