+ 1

Can i access default access modifier in other package after importing that package and inheriting the desired class?

Java

6th Jun 2017, 3:07 AM
Mahesh Dudhnale
Mahesh Dudhnale - avatar
2 ответов
+ 1
Default is package private so... no. If I understand you correctly. Example In package a.b.c, we have: public class A { int d = 3; } In another package x.y.z we have: import a.b.c.A; public class X { public void main(String[] args) { A var = new A(); int x = var.d; // error! d is package private } }
6th Jun 2017, 4:13 AM
Jason Runkle
Jason Runkle - avatar
0
thank you buddy! that exactly was my question.
6th Jun 2017, 5:18 AM
Mahesh Dudhnale
Mahesh Dudhnale - avatar