Import a custom class in Java

前端 未结 7 1416
悲哀的现实
悲哀的现实 2020-11-29 06:57

How do I import a class I wrote in a different file? All my classes are under the same package.

相关标签:
7条回答
  • 2020-11-29 07:54

    Import by using the import keyword:

    import package.myclass;
    

    But since it's the default package and same, you just create a new instance like:

    elf ob = new elf(); //Instance of elf class
    
    0 讨论(0)
提交回复
热议问题