0
If we create new class which has a instance variable int a, without access modified, then what will the access level of int x be
class A{ private int x = 2; // what if only declare int x= 2? } public class Program { public static void main(String[] args) { A a = new A(); System.out.println(a.x); a.x = 3; System.out.println(a.x); } }
1 Réponse
+ 1
why don't you try it?
Google searching it, the access level is package-private.
https://stackoverflow.com/questions/215497/what-is-the-difference-between-public-protected-package-private-and-private-in