简体   繁体   中英

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......

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 Name
{
  void showname()
  {
    System.out.println("Satwinder");
  }
}

Class names can only contains IDs (basically az, AZ, 0-9 and _) and .

Edit your question to show the code how you try to access the class.

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