I have some questions about Java Compiler.
My current directory is like this.
├── Hoge.java
├── Sample.class
├── Sample.java
├── pattern01
│ └── com
│ └── cat
│ └── Hoge.class
└── pattern02
└── com
└── cat
└── Hoge.class
----- Sample.java -----
import com.cat.Hoge;
public class Sample {
public static void main(String[] args) {
System.out.println("hello!");
Hoge h = new Hoge();
h.call();
}
}
----- pattern01 -----
package com.cat;
public class Hoge {
public void call() {
System.out.println("com.cat");
System.out.println("pattern01");
}
}
----- pattern02 -----
package com.cat;
public class Hoge {
public void call() {
System.out.println("com.cat");
System.out.println("pattern02");
}
}
I compiled Sample.java like this.
$ javac -cp pattern01 Sample.java
And I execute it like this.
$ java -cp .:pattern01 Sample
hello!
com.cat
pattern01
$ java -cp .:pattern02 Sample
hello!
com.cat
pattern02
Both pattern01 and pattern02 are normally ended.
But I compiled with pattern01. Why did program normally end with pattern02?
What does compiler check? Does compiler check only class name ?