This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in accessing a method

 
Prashanth Patha
Ranch Hand
Posts: 62
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose we have a class as follows:

package prash;
public class A // public class
{

void print() { // default access
System.out.print("Hi");
}

}

Consider another class:

package ravi;
import prash.A;
class B
{
// Doubt:
// Can B access the method print() (having default access ) of a public class A which is in different package?
}








 
Evelina Vrabie
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, default access means package-private (only visible inside the package). Take a look here: http://download.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
 
Ikpefua Jacob-Obinyan
Ranch Hand
Posts: 394
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Prashanth, please use code tags to make code reading easier



As you can observe, it is easier to read now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic