//同类packagemypractice;publicclassThreeDemo{privateint a =10;protectedint b =10;int c =10;publicint d =10;publicvoidstudy(){
a++;
b++;
c++;
d++;}}
//同包不同类packagemypractice;publicclassTest{publicstaticvoidmain(String[] args){ThreeDemo td =newThreeDemo();int b = td.b;//不能访问td.aint c = td.c;int d = td.d;}}
//不同包不同类packagehomework;importmypractice.ThreeDemo;publicclassTestWork{publicstaticvoidmain(String[] args){ThreeDemo td =newThreeDemo();int d = td.d;//仅能访问td.d}}