File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Declaration and Access Control Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic

Declaration and Access Control

Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 250

Hi friends...
I am having a problem in understanding why this code is giving error. Please help...

Astha - OCPJP 6 (90%)
Ankit Garg

Joined: Aug 03, 2008
Posts: 9463

Your code is missing curly brackets for the main method...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Astha Sharma
Ranch Hand

Joined: Oct 15, 2011
Posts: 250

oops...i did it by mistake :O
but if i am putting curly brackets, then also its giving an error. Let me post the modified code in new thread.
Aniket S. Kulkarni
Ranch Hand

Joined: Jun 15, 2011
Posts: 87

Ankit Garg is right and in println you are calling method without creating the object of Hobbit class.

Aniket Kulkarni
Oracle Certified Professional, Java SE 6 Programmer.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
continued here

Next time, you can just continue the discussion in the same topic, as it is about the same subject.
I agree. Here's the link:
subject: Declaration and Access Control
It's not a secret anymore!