简体   繁体   English

关于简单Java挑战的复杂思考,我该如何解决?

[英]complex thinking on simple java challenge, how can i fix it?

Simple stuff but somehow not able to crack it, below piece of code gives compile time exception like unexpected token at try/catch and unhandled exception:java.io.FileNotFound 简单的东西,但是以某种方式无法破解,下面的代码给出了编译时异常,例如try/catch unexpected tokenunhandled exception:java.io.FileNotFound

 String fileName = "C:\\GS.xlsx";
 try{
        CSVReader reader = new CSVReader(new FileReader(fileName));
 }catch(Exception e){

 }

What is the possible issue in here, i know there is something really goofy that am doing in here... 这可能是什么问题,我知道这里确实有些愚蠢...

Update 更新

Issue was, I didn't had my code in method...result of longs hrs of continous work... 问题是,我的方法中没有代码...长时间连续工作的结果...

 public class PositionGS {

    public PositionGS() {
        String fileName = "C:\\GS.xlsx";
        try {
            CSVReader reader = new CSVReader(new FileReader(fileName));
        } catch (Exception e) {
        }
    }
}

that's the complete code... 这是完整的代码...

您需要将此代码放在方法或构造函数内部,而不是放在类中。

Are you sure this is the complete code? 您确定这是完整的代码吗? Your code is written right inside the class body and not inside any method or function!! 您的代码直接写在类主体内部,而不是写在任何方法或函数内部!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM