leegold2
Technical User
- Oct 10, 2004
- 116
Hi,
This is a basic question. I'm learning Java on XP. I'm noticing the way Java behaves that raises a question. Let's say I have folder with Test1.class it's got a printNames method that prints out an array. Now in same folder I write and compile Test2.java - it compiles with no errors. Test2 code might be this:
class Test2 {
public static void main (String arguments[]){
Test1 a = new Test1();
a.printNames();
}
}
And an array defined in test1 is outputted. Why does this happen? I do not explictly import test1 into the test2 class. What cache or default mechanism allows one class to see and use another class to make an object? Is there a way to prevent this, so that it will only happen if I explictly allow it in the code? Csn't this default capability cause trouble?
I also tried to clear all caches and temp files and removed the test1 class to the recycle bin. Test1 still worked in test2.
Help to understand appreciated.
Lee G.
This is a basic question. I'm learning Java on XP. I'm noticing the way Java behaves that raises a question. Let's say I have folder with Test1.class it's got a printNames method that prints out an array. Now in same folder I write and compile Test2.java - it compiles with no errors. Test2 code might be this:
class Test2 {
public static void main (String arguments[]){
Test1 a = new Test1();
a.printNames();
}
}
And an array defined in test1 is outputted. Why does this happen? I do not explictly import test1 into the test2 class. What cache or default mechanism allows one class to see and use another class to make an object? Is there a way to prevent this, so that it will only happen if I explictly allow it in the code? Csn't this default capability cause trouble?
I also tried to clear all caches and temp files and removed the test1 class to the recycle bin. Test1 still worked in test2.
Help to understand appreciated.
Lee G.