为什么我的程序不起作用?不断收到找不到符号错误?

Why my program no work ? keep getting cannot find symbol error?

尝试在我的主代码中创建子类 h 对象时,我一直遇到找不到符号错误。有人可以帮忙吗?谢谢

似乎主程序正在接受 inhtt 对象,但是当我尝试调用 h 对象时,它说找不到符号并要求我创建 h 对象。

public class inhtt {
   //class methods
  public  int thing; 
    public int stuff ;
    public int otherstuff;

  // constructor based on parameters
 public inhtt( int x, int y, int z){
        thing = x;
        stuff = y;
        otherstuff = z;
    }    
 void showmain (){
    System.out.println("thing is " + thing);
    System.out.println("stuff is " + stuff);
    System.out.println("otherstuff is " + otherstuff);
}

public class h extends inhtt {
  int beard; 
  h( int x, int y, int z, int a){
      super(x,y,z);
        beard = a;
  }
  void shownewa(){
    System.out.println("beard is" +beard);  
 }
}
}



 * @author New User
 */
public class runraffharsh {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
     inhtt base = new inhtt(1,1,1);
     base.showmain();

     h = new h(1,1,1,1);
     h.shownew();

//      raff beard = new raff(1,1,1,1);
//     beard.showbeard();
//     

    }

}

您对继承 class h 的引用有疑问。你定义了 showewa() 但试图访问 shownew()

此代码存在多个问题:

  1. h 是内在的 class 到 inhtt。由于它不是静态的,因此您需要使用 base.new h(1,1,1,1); 之类的东西来实例化它。

  2. 您需要声明一个变量以将新的 h 实例分配给。为整行尝试类似 inhtt.h h = base.new h(1,1,1,1); 的内容。

  3. h (class) 没有名为 shownew 的方法。它有一个名为 shownewa.

  4. 的方法
  5. runraffharshinhtt都是publicclass。它们需要放在单独的文件中。

  6. runraffharsh上面的评论区没有正常打开