如何将界面放在单独的文件中? [英] How can I put interface in a seperate file?
本文介绍了如何将界面放在单独的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我被这个错误困扰.我想将我的接口和类放在单独的文件中.但是编译器抛出错误.任何建议将不胜感激
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
这篇关于如何将界面放在单独的文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文