I have compiled this program and it created a class file in the same folder.
I created another program in the folder c:\javatest
The second program gives compilation error:
cannot find symbol
symbol: variable i
location class parent.
Then I replaced the i with public variable j, assuming because it was declared protected it gave compilation error, but still for variable j, even though it was declared as public it gives the same compilation error. can anybody throw some light on it please.
He had a excellent query(accessing outer package from inner package) after several attempts he got the answer for that!
you have to just include the java -cp <path> <filename.java> command to compile
. for current directory
.. for parent directory
you can use these relative naming pattern for setting appropriate path
Also have you placed the second file in a package or not .i suppose you have not !
Also most people do not know protected fields are accessible only through inheritance,you cannot make a reference and access a protected field i suppose this is not the major cause as you were saying it gives same error when field is changed to public !so it got to be the classpath problem please read the above and if you have time read the Package Problem from Ashutosh Chauhan!
As you have extended the parent class, its variables can be accesed by the child class. the parent class is in a subdirectory p. so you cannot access it through the object of the parent class. try it by an object of the child class itself.