简体   繁体   English

如何在同一 package 中访问主 class 中的类

[英]How to access classess in main class within same package

I got one problem while accessing classes in main class within a same package.... it shows error like "bad class name\name.class......我在同一 package 中访问主 class 中的类时遇到了一个问题。

public class Showall
{
  void print()
  {
    System.out.println("We Will show all the details");
  }

  public static void main(String args[])
  {
    Showall sa=new Showall();
    sa.print();
    Name n=new Name();
    n.showname();
  }
}

............................. here Name is class which is placed in same package. .............................这里的名称是 class,它位于同一个 package 中。 .................................. .....................................

class Name
{
  void showname()
  {
    System.out.println("Satwinder");
  }
}

Class names can only contains IDs (basically az, AZ, 0-9 and _) and . Class 名称只能包含 ID(基本上是 az、AZ、0-9 和 _)和.

Edit your question to show the code how you try to access the class.编辑您的问题以显示您如何尝试访问 class 的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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