如何将界面放在单独的文件中?

编程入门 行业动态 更新时间:2024-10-23 10:21:24
本文介绍了如何将界面放在单独的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我被这个错误困扰.我想将我的接口和类放在单独的文件中.但是编译器抛出错误.任何建议将不胜感激

I am stuck with this error. I want to put my interface and class in separate files. But the compiler is throwing an error. Any suggestion will be appreciated

我已经创建了一个接口和类

I have create an interface and class

.. test \ t1.java

package test; interface t1 { public void sayHello(); }

.. \ test \ HelloWorld.java

package test; public class HelloWorld implements t1 { public void sayHello() { System.out.println("Hello World"); } public static void main(String args[]) { HelloWorld h=new HelloWorld(); h.sayHello(); } }

我尝试编译它,但是编译器抛出错误

I tried to compile it but the compiler is throwing an error

test>javac HelloWorld.java HelloWorld.java:3: error: cannot find symbol public class HelloWorld implements t1 ^ symbol: class t1 1 error

推荐答案

用于编译

我没有提供完整的路径

javac -classpath e:\user\java; HelloWorld.java

运行

我没有在类名中包含要执行的有效程序包名称.

I didn't include the valid package name with class name for execution.

E:\user\java\test>java -classpath e:\user\java\; test.HelloWorld Hello World

更多推荐

如何将界面放在单独的文件中?

本文发布于:2023-11-24 09:09:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624599.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:放在   如何将   界面   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!