我用的是netbeans ide 4.1,我按照官方教程编程序,有两个项目,一个用来定义一个类LibClass,类中有一个函数public static String acrostic(String[] args),还有一个主项目,里面是主类,可是我在主类里引用LibClass类时出了问题,
public static void main(String[] args) {
String result=LibClass.acrostic(args);
System.out.println("Result+"+result);
}
其中第二句String result=LibClass.acrostic(args);报错,错误是:
cannot find symbol,
symbol:variable LibClass
location:class org.me.myapp.AcrosticExample
其中AcrosticExample是我改了名的主类。
请问这是为什么?怎么解决?谢谢!
public static void main(String[] args) {
String result=LibClass.acrostic(args);
System.out.println("Result+"+result);
}
其中第二句String result=LibClass.acrostic(args);报错,错误是:
cannot find symbol,
symbol:variable LibClass
location:class org.me.myapp.AcrosticExample
其中AcrosticExample是我改了名的主类。
请问这是为什么?怎么解决?谢谢!
解决方案 »
- 用JAVA实现Telnet;采用TelnetProtocolHandler实现;但是批处理命令时会出现时序不一致的情况!请大侠们看看如果保证输入输出一致!
- 群发软件的代码
- 如何更改程序外观阿?分给的多
- 能不能用APPLET实现文件上传?
- 有谁知道JBUILDER9下的中文乱码问题
- 谁能提供一个sql2000的高效分页程序?分数不够再加
- 请问如果判别所得字符串是中文还是英文或数字 ?(有无这样的基础类)
- java的安装方法和配置方法
- 高分请教一个Timer类的简单问题!一定送高分!
- 如何自定义一个对话框,然后在Applet中弹出该对话框(模式)
- 编一个无穷循环的While语句,直到敲键盘中断程序
- 请教:怎样通过窗口的关闭按钮关闭GUI应用程序?
----------------
如果java文件有public类,则文件名必须与该类名一直,不能随便改名
不知道楼主具体是什么情况
package org.me.myapp;
/*
* AcrosticExample.java
*
* Created on 2005年12月13日, 下午7:49
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*//**
*
* @author Administrator
*/
public class AcrosticExample {
/**
* Creates a new instance of AcrosticExample
*/
public AcrosticExample() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String result=LibClass.acrostic(args);
System.out.println("Result+"+result);
}
}
这个是另一个类:
package org.me.mylib;/**
*
* @author Administrator
*/
public class LibClass {
/** Creates a new instance of LibClass */
public static String acrostic(String[] args) {
StringBuffer b = new StringBuffer();
for (int i = 0; i < args.length; i++) {
if (args[i].length() > i) {
b.append(args[i].charAt(i));
} else {
b.append('?');
}
}
return b.toString();
}
public LibClass() {
}
}
这都是网上教程中的程序。