氟塑料离心泵www.buybeng.com

jquery教程http://www.software8.co/wzjs/jquery/

总结Java会出现"unreachable code"错误的几个例子

1. throw关键字

Java代码:  
  1. public void XXX() throws Throwable{  
  2.     throw new Throwable();  
  3.     System.out.println("test");  
  4. }  

2. return关键字

Java代码 : 
  1. public void XXX() {  
  2.     return;  
  3.     System.out.println("test");  
  4. }  

3. continue关键字

Java代码:  
  1. public void XXX() {  
  2.     for(int i=0; i<10; i++) {  
  3.         continue;  
  4.         System.out.println("test");  
  5.     }  
  6. }  

4. break关键字

Java代码:  
  1. public void XXX() {  
  2.     for(int i=0; i<10; i++) {  
  3.         if(i==5) {  
  4.             break;  
  5.             System.out.println("test");  
  6.         }  
  7.     }  
  8. }  

5. while(true):

Java代码:  
  1. public static void XXX() {  
  2.     while(true);  
  3.     System.out.println("when?");  
  4. }  
原文参考自站长网http://www.software8.co/wzjs/java/2821.html

以上均会出现编译错误:

posted on 2013-01-22 17:23 你爸是李刚 阅读(4789) 评论(1)  编辑  收藏

评论

# re: 总结Java会出现"unreachable code"错误的几个例子[未登录] 2014-04-14 19:28 123

@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnStart) {
while(true){}
btnStart.setEnabled(false);
start = true;
x = r.nextInt(38);
y = r.nextInt(32);
snackLocation s = new snackLocation();
s.setX(20);
s.setY(15);
list.add(s);
th = new Thread(this);
th.start();
this.requestFocus(true);
repaint();
}
if (e.getSource() == btnStop) {
System.exit(0);
}
if (e.getSource() == btnOK) {
list.clear();
score = 0;
speed = 1;
btnStart.setEnabled(true);
start = false;
dia.setVisible(false);
repaint();
}
}
  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2013年1月>
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

导航

统计

常用链接

留言簿

随笔档案

文章档案

技术网站

行业网站

搜索

最新评论

阅读排行榜

评论排行榜

站长网 氟塑料离心泵 注塑机 液晶广告机