为什么会出现错误“文件无法解析为类型"? [英] Why do I get the error "File cannot be resolved to a type"?

查看:111
本文介绍了为什么会出现错误“文件无法解析为类型"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码的一部分

try{

    BufferedReader in= new BufferedReader(new InputStreamReader(System.in));

    while ((line= in.readLine())!="exit"){

    System.out.println("Enter command");
    line=in.readLine();
    Command currentCommand=new Command(line);



    File currentFile= new File(currentCommand.getLsPath());

方法 currentCommand.getLsPath()返回一个字符串,该字符串对于File Constracture是必需的,但仍然出现此错误: File无法解析为类型

The method currentCommand.getLsPath() returns a string, which is mendatory for the File Constracture, and still I get this error: File cannot be resolved to a type

出什么问题了?

推荐答案

您刚刚错过的机会:

import java.io.File;

从源文件的顶部开始.

可以使用

 import java.io.*; 

我通常使用单类型导入.

I typically use single-type imports.

这篇关于为什么会出现错误“文件无法解析为类型"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆