Welcome
Welcome to <strong>Developer</strong>.

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

About issue of public access in K&B book

Exchange experience in SCJP.

About issue of public access in K&B book

Postby developer on Sun May 11, 2008 10:12 am

In K&B book page 29, it says:

Code: Select all
class Toon { 
  public static void main(String[] args) {   
    Cloo c = new Cloo();   
    System.out.println(c.doRooThings()); //No problem; method is public 
  }
}


What I want to know is if class Toon and Cloo are in different packages, it will be compiling error or not?
Because class Cloo is default access not public.
developer
Site Admin
 
Posts: 37
Joined: Thu Jan 31, 2008 8:26 pm

Postby developer on Sun May 11, 2008 10:16 am

Class Toon should also be in package notcert.
Otherwise, it will show compiling error: The type notcert.Cloo is not visible.

If class A itself cannot be accessed by class B, then no members within class A can be accessed by class B.
developer
Site Admin
 
Posts: 37
Joined: Thu Jan 31, 2008 8:26 pm


Return to SCJP

Who is online

Users browsing this forum: No registered users and 0 guests

cron