You cannot access protected variable of A inside B. Therefore your code will not compile.
===============================================
6.6.2 Details on protected Access
A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object.
===============================================
It will compile:
1) If you'll change code like this
package p2;
import p1.*;
public class B extends A{
public void process(B b){//new
b.i = b.i*2;
}
public static void main(String[] args){
A a = new B();
B b = new B();
b.process((B)a);//new
System.out.println( a.getI() );
}
}
1) or change package
package p1;
import p1.*;
public class B extends A{
...
}
Jamal Hasanov
www.j-think.com