Java Import Package (to package above present work directory)

how do I import package (to package above present work directory) in Java? here is the directory structure: [![enter image description here][1]][1] **Coba.java** import halo.*; public class Coba { public static void main(String args[]) { Orang org = new Orang(); System.out.println(org.a); } } **Orang.java** package halo; // I can't import kabar.*; since it's above present work directory public class Orang { public int a; public Orang() { this.a = 1; } public void haha() { /* i want to: Tes t = new Tes(); System.out.println(t.b); */ } } **Tes.java** package kabar; public class Tes { public int b; public Tes() { this.b = 2; } } **Question:** How do I access variable b in class Tes by importing class kabar.Tes from class Orang? If i write import kabar.Tes; in class Orang. It doesn't work because class Orang is above present work directory. Thank you very much. BTW, I don't use Netbeans or Eclipse. I want to know the basic how it works, so I just use simple text editor. [1]: https://i.stack.imgur.com/Cwj5s.png

以上就是Java Import Package (to package above present work directory)的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏