Eclipse不会编译

时间:2016-03-06 03:16:12

标签: eclipse compilation

因此。我正在写这段代码:

https://www.youtube.com/watch?v=pHxtKDENDdE&list=PLFE2CE09D83EE3E28&index=30

这是代码。这与Youtube视频中的相同:

import java.util.Random;

class ArrayElementsasCounters {    
    public static void main(String[] args) {            
        Random rand = new Random();
        int freq[] = new int[7];

        for(int roll=1;roll<1000;roll++) {              
            ++freq[1+rand.nextInt(6)];                              
        }

        System.out.println("Face\tFrequency");

        for(int face=1;face<freq.length;face++); {
            System.out.println(face+"\t"+freq[face]);
        }           
        }               
    }

我收到了这个编译错误:

  

线程“main”中的异常java.lang.Error:未解析的编译   问题:面部无法解决变形面不能   解决了变量

     

在ArrayElementsasCounters.main(ArrayElementsasCounters.java:22)

     

第22行是: System.out.println(face +“\ t”+ freq [face]);

这对于Youtube视频中的人来说非常合适,但不适合我。为什么?

1 个答案:

答案 0 :(得分:2)

在for语句之后删除半冒号..

for(int face=1;face<freq.length;face++);

在代码中删除此分号..

相关问题