Hello Everyone,
I have following two .java files in the same directory and CLASSPATH is set to "."(Current working directory)
Please Note : I am compiling and running from command prompt
// Use.java
code:
class Use {
public static void main(
String [] args){
Provider p = new Provider();
System.out.println(p.name);
p.getMessage();
}
}
//Provider.java
code:
class Provider {
String name = "hi how are you? Bharat"; // Line #1
void getMessage(){ // Line #2
System.out.println("You have Message !!!");
}
}
Now, I compile these two files and if I run Use class,it prints
hi how are you? Bharat
You have Message
Everything is fine upto this. Now I change access modifier at Line #1 and Line #2 from default to private in Provider.java file, I also change variable name's value for "hi how are you? Bharat" to " are you there ?"(at Line #1). I also delete Provider.class file.
After these modifications, I recompile Provider.java file (Please Note:I have just recompile Provider.java file, NOT Use.java) and then if I run , Use class file,it prints
are you there ?
You have Message
I have no idea, how's this possible ?? Can anyone explain me what's going on behind the scene ?
Thank You
[ June 21, 2007: Message edited by: Bharat Makwana ]