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
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
SCJP Exercise 5-3 for help.
Kurt Zhu
Greenhorn
Posts: 8
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I read some earlier topics but not a lot of them, which I think not meet the exercise's requirements well.
I had mine here. Can any one help check whether it meets the requirements and if so to what extent. Thank you.
class Propagate{ public static void main(String[] args){ try{ System.out.println(reverse("ab")); }catch(Exception e){ e.printStackTrace(); //it requires that main() must deal with the exception, not throw it. }finally{ System.out.println("end of main() in the finally block."); // it requires a finally{} block indicating something. } } static String reverse(String s) throws Exception{ if(s.length()==0){ throw new Exception(); } String reverseStr = ""; for(int i = s.length()-1; i>=0; --i){ reverseStr += s.charAt(i); } return reverseStr; } }
Ankit Garg
Sheriff
Posts: 9707
43
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Kurt if you can include the question as well that would be better as not everyone has the book (mine is with a friend
)...
SCJP 6 | SCWCD 5 |
Javaranch SCJP FAQ
|
SCWCD Links
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Propogating Exceptions - Exercise5.3 in K&B
Exercise on Propagating Exceptions. Am I missing something?
K&B - Exercise - try/catch problem
missing return statement error message when compiling class
Propagating and Catching an exception problem
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...