简体   繁体   中英

Import java file in the same folder

I have made a file A.java and another B.java. A and B are in the same folder. B has

  A a = new A(); 

How do I import A to B ?

I am not using any ide. Running it on hadoop framework

image

No need of importing files. Just compile and run. As in the picture 1 you can you can compile both files and run the class with the main method . In my case my main method is in DogTest.java file in or You can just compile your java file which includes the main() method and run.

Classes that are in the same package do not need to import from other classes in the package, provided that the class isn't private. So in your case, you shouldn't need to worry about importing, as A is, by default, imported to B so long as A isn't private.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM