Java package mangement question

62 阅读1分钟

Java package mangement
these are my codes and current dir path
tree .
.
├── hello
│ ├── car
│ │ ├── car.class
│ │ └── car.java
│ └── hello.java
├── Main.class
├── Main.java

here are codes
Main.java

import hello.hello;
public class Main{
    int x=5;
    public static void main(String[] args){
        hello h=new hello();
        h.print();
        hello.main(args);
    }
    static void myMethod(){
        System.out.println("myMethod");
    }
}

hello.java

package hello;
import hello.car.car;
public class hello{
    public void print(){
        System.out.println("hello world!");
    }
    public static void main(String[] args){
        car c=new car();
        c.print();
    }
}

car.java

package hello.car;
public class car{
    public void print(){
        System.out.println("car!");
    }
}

here are outputs
under hello dir,

$javac hello.java   
hello.java:2: error: package hello.car does not exist  
import hello.car.car;  
hello.java:8: error: cannot find symbol  
        car c=new car();  
  symbol:   class car  
  location: class hello  
hello.java:8: error: cannot find symbol  
        car c=new car();  
  symbol:   class car  
  location: class hello  
3 errors  

could you help me figure out this problem?