请问为什么代码通过了编译,果实却运行不了? 如题,请问是不是我配置环境变量配置错了? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在CMD里面说:Exception in thread "main" java.lang.NoClassDefFoundError: C:\1000\Example2_1/class初学JAVA,所以看不懂``` main方法里面没有发现类,C:\1000\Example2_1/class public class Example2_1{ public static void main(String args[]) { char chinaWord='你',japanWord=' '; int p1=20328,p2=12358; System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (intchinaWord); System.out.println("日语\' \'字在unicode表中的顺序位置:" + (int)japanWord); System.out.println("unicode表中第20328位置上的字符是:" + (char)p1); System.out.println("unicode表中第12358位置上的字符是:" + (char)p2);}} 可能你文件没有保存为Example2_1还有就是可能CLASS_PATH少了.; System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (intchinaWord);少了个括号("汉字\'你\'字在unicode表中的顺序位置:" + (int)chinaWord); System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (intchinaWord);???可能是写错了只能说程序没有问题,看看CLASS_PATH 在classpath最前面加上.;就是一个点,一个分号.点代表当前路径.如果你没有classpath,那么会默认当前路径.如果你有classpath,就没有默认路径了.java虚拟机不会在当前目录下寻找你的class文件,只会在classpath中去找.所以说找不到class 这段代码我这里能运行啊!估计是你环境变量配错了,或者JVM有问题了,我以前也遇到过类似问题,重装一下jdk试试吧!应该不是大问题吧 System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (intchinaWord);1、缺少括号2、没有intchinaWord这个变量。 System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (intchinaWord);改为:System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (int)chinaWord);结果如下:汉字'你'字在unicode表中的顺序位置:20320日语' '字在unicode表中的顺序位置:32unicode表中第20328位置上的字符是:佨unicode表中第12358位置上的字符是:う你的问题肯定是环境变量的问题. public class Example2_1{ public static void main(String args[]){ System.out.println("fsafsd"); String japanWord="11"; int p1=20328,p2=12358; System.out.println(Integer.parseInt(japanWord)); System.out.println("unicode表中第20328位置上的字符是:" + (char)p1); System.out.println("unicode表中第12358位置上的字符是:" + (char)p2); }}你如果要转japanWord而且如果是字符的类弄就要赋值不然他转的时候不知道是啥类型的这样就会报错 java 应用软件开发问题 关于泛型的理解问题 接口回调 16进制有符号数字符串为 FF2B 怎么写java代码,转换为 -213 ?谢谢 java 网络编程。高手 请进来 看看 ClassCastException 如何实现JButton的按下下陷,再按下弹起效果???在线等待 如何做移动agent??(在线等) 请高手赐教! 提问,^_^& JAVA中String对象的赋值疑问 求解:高手帮忙运行一下
{
public static void main(String args[])
{
char chinaWord='你',japanWord=' ';
int p1=20328,p2=12358;
System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (intchinaWord);
System.out.println("日语\' \'字在unicode表中的顺序位置:" + (int)japanWord);
System.out.println("unicode表中第20328位置上的字符是:" + (char)p1);
System.out.println("unicode表中第12358位置上的字符是:" + (char)p2);
}
}
还有就是可能CLASS_PATH少了.;
少了个括号("汉字\'你\'字在unicode表中的顺序位置:" + (int)chinaWord);
???可能是写错了只能说程序没有问题,看看CLASS_PATH
就是一个点,一个分号.点代表当前路径.
如果你没有classpath,那么会默认当前路径.
如果你有classpath,就没有默认路径了.java虚拟机不会在当前目录下寻找你的class文件,只会在classpath中去找.所以说找不到class
2、没有intchinaWord这个变量。
改为:
System.out.println("汉字\'你\'字在unicode表中的顺序位置:" + (int)chinaWord);结果如下:
汉字'你'字在unicode表中的顺序位置:20320
日语' '字在unicode表中的顺序位置:32
unicode表中第20328位置上的字符是:佨
unicode表中第12358位置上的字符是:う你的问题肯定是环境变量的问题.
public static void main(String args[]){
System.out.println("fsafsd");
String japanWord="11";
int p1=20328,p2=12358;
System.out.println(Integer.parseInt(japanWord));
System.out.println("unicode表中第20328位置上的字符是:" + (char)p1);
System.out.println("unicode表中第12358位置上的字符是:" + (char)p2);
}
}
你如果要转japanWord而且如果是字符的类弄就要赋值不然他转的时候不知道是啥类型的这样就会报错