Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

different packages

 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose you want to write following statement:
Shape s = new circle()
Whereas circle is a type of Shape. If Shape and
circle both happen to be in different package, do
they both have to Public or just Shape can be
public only....
 
Jose Botella
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That depends where the statement is.
If it's in a class within the package in which Shape is defined, you will need to import circle and circle must be public. However if it's in a class within the package where circle is defined, it's necessary to import Shape and Shape must be public.
That is, a class needs to be public if is going to be referred from another package in which was declared.
[ August 15, 2002: Message edited by: Jose Botella ]
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So here is the scenario:
Shape and Circle both in same package. The client
class that is calling these classes with statement:
Shape s = new Circle;
is in a different package. Do we have to have
Shape and Circle both public or only one of them?
Thanks
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both.
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ron
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic