Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Paul Clapham
Liutauras Vilda
Sheriffs:
Junilu Lacar
Rob Spoor
Jeanne Boyarsky
Saloon Keepers:
Stephan van Hulst
Carey Brown
Tim Holloway
Piet Souris
Bartenders:
Forum:
Programmer Certification (OCPJP)
Compile Error
laoniu gougou
Greenhorn
Posts: 25
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can anybody explain to me why the compile fail:
public class ThrowsDemo {
static void throwMethod() {
System.out.println("Inside throwMethod.");
throw new IllegalAccessException("demo");
}
public static void main(
String
args[]) {
try {
throwMethod();
} catch (IllegalAccessException e) {
System.out.println("Caught " + e);
}
}
}
Hungson Le
Ranch Hand
Posts: 32
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You should
indicate that your function might throw an exception
using the throws clause
static void throwMethod() throws IllegalAccessException { System.out.println("Inside throwMethod."); throw new IllegalAccessException("demo"); }
LHS
[This message has been edited by Hungson Le (edited March 16, 2001).]
Hungson Le<BR>
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JavaCap no. 10
Do Static methods throw exceptions?
Exception Q?
Java Caps Mock
throw an Exception....
More...