Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Explain me printStackTrace??

 
Ranch Hand
Posts: 216
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

//It is printing numbers but what does it exactly do???
[ Jess fixed the [code] block ]
[ March 26, 2003: Message edited by: Jessica Sant ]
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The printStackTrace method is a method of the Throwable class - the superclass of all Exceptions. Basically, it just prints out where the Exception in question occurred by giving you the list of method calls that resulted in the Exception being thrown. It's very useful for debugging!
Incidentally, it's got nothing to do with the numbers your code is printing out - they're from the running thread's run method, which is just incrementing i and printing the result...
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Do I need to know what the methods fillInStackTrace() and printStackTrace() do for the exam?
Do I also need to know how to throw an object of type Throwable for the exam?
[ March 26, 2003: Message edited by: Karin Paola Illuminate ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the exam objectives state:
  • Write code that makes proper use of exceptions and exception handling clauses (try, catch, finally) and declares methods and overriding methods that throw exceptions.
  • Recognize the effect of an exception arising at a specified point in a code fragment. Note: The exception may be a runtime exception, a checked exception, or an error (the code may include try, catch, or finally clauses in any legitimate combination).


  • So... you definitely need to know how to use a try /catch block -- and the finally clause too. You should understand the difference between checked / unchecked exceptions -- (and the basic Exception class hierarchy too).
    However (according to the Sierra/Bates book) For th exam, it is not necessary to know any of the methods contained in the class Throwable... You are expected to know tha Exeption, Error, RuntimeException, and Throwable types can all be thrown using the throws keyword, and can all be caught (although you rarely will catch anything other than Exception subtypes).
     
    Karin Paola Illuminate
    Ranch Hand
    Posts: 109
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Jessica. Thanks.
     
    Tongue wrestling. It's not what you think. And here, take this tiny ad. You'll need it.
    Thread Boost feature
    https://coderanch.com/t/674455/Thread-Boost-feature
      Bookmark Topic Watch Topic
    • New Topic