在下是初学者,请各位前辈给些高见...谢谢...public class Exe1 {
public static void main(String[] args) {
String a[]={"door","apple","Applet","girl","boy"};
for(int i=0;i<a.length-1;i++);
{
for(int j=i+1;j<a.length;j++);
{
if(a[j].compareTo(a[i])<0)
{
String temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
for(int i=0;i<a.length;i++)
{
System.out.println(" "+a[i]);
}
}
}
运行后出错信息如下:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
i cannot be resolved
j cannot be resolved
i cannot be resolved
i cannot be resolved
i cannot be resolved
j cannot be resolved
j cannot be resolved at First.Exe1.main(Exe1.java:12)
谢谢关注...
楼主【cswudafeng】截止到2008-06-25 22:40:19的历史汇总数据(不包括此帖):
发帖数:24 发帖分:830
结贴数:22 结贴分:630
未结数:2 未结分:200
结贴率:91.67 % 结分率:75.90 %
值得尊敬
楼主【cswudafeng】截止到2008-06-25 22:40:19的历史汇总数据(不包括此帖):
发帖数:24 发帖分:830
结贴数:22 结贴分:630
未结数:2 未结分:200
结贴率:91.67 % 结分率:75.90 %
值得尊敬
{
for(int j=i+1;j<a.length;j++);
把这两个for循环后的分号去掉试试。细心,呵呵
for(int i=0;i<a.length-1;i++);
这一句 多了个分号
for(int i=0;i<a.length-1;i++);
for(int j=i+1;j<a.length;j++);
去掉冒号就可以了
for(int i=0;i<a.length-1;i++)
for(int j=i+1;j<a.length;j++)
for(int j=i+1;j<a.length;j++);
为什么加个;?