Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TrynCatch

 
Roberto Diaz
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have following code which works just fine.

But if I add the print statement in class B it
fails to compile.
Can anyone expalin whatz going on behind the scenes??
TIA.
[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ January 14, 2003: Message edited by: Jessica Sant ]
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its actually pretty simple
the System.out.println statement needs to be inside a method or a constructor:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic