日期:2014-05-20  浏览次数:20600 次

程序帮忙给该一下!
package   yan1;

class   Yan4   extends   Thread{
public   Yan4(String   str){
super(str);
}
public   void   run(){
System.out.println( "xian   cheng   2 "+getName()+ "begin ");
for(char   ch= 'A ';ch <= 'Z ';ch++);
{
System.out.println(ch);
try
{
sleep(100);
}
catch(InterruptedException   e)
{
System.out.println( "xian   cheng2   error ");

}
}
}
}
class   Yan2   extends   Thread
{public   Yan2(String   str)  
{
super(str);  
 
 
}  

public   void   run(){
System.out.println( "xian   cheng   1 "+getName()+ "begin ");  
for(int   i=1;i <=26;i++)
{System.out.println(i);
try
{sleep(2000);
}
catch(InterruptedException   e)
{System.out.println( "xian   cheng   1   have   error ");
}
}
}
public   static   void   main(String[]   args)
{new   Yan4( "1 ").start();
new   Yan2( "2 ").start();
}  
}

有一处错误在:
System.out.println(ch);


------解决方案--------------------
你的ch的有效范围只在for语句里,把它定义在外面:
char ch;
for(ch= 'A ';ch <= 'Z ';ch++)
System.out.println(ch);