简体   繁体   English

Eclipse 自动导入扫描仪类?

[英]Eclipse auto-import Scanner class?

I've been using Eclipse on a few computers recently, and since using it on my home computer, have found that it doesn't automatically import java.util.* or java.util.Scanner after declaring a Scanner class in my code.我最近一直在几台计算机上使用 Eclipse,自从在我的家用计算机上使用它以来,我发现在我的代码中声明 Scanner 类后,它不会自动导入 java.util.* 或 java.util.Scanner。

In my code, I type something like:在我的代码中,我输入如下内容:

Scanner sc = new Scanner(System.in);

... and in the past, Eclipse would add the import java.util.Scanner or import java.util.* line above my class. ...在过去,Eclipse 会在我的类上方添加import java.util.Scannerimport java.util.*行。

Any idea how I could get the program to do this for me?知道如何让程序为我做这件事吗? I know it's a very insignificant thing, but everything I learn about Eclipse or programming makes me a stronger programmer :)我知道这是一件非常微不足道的事情,但是我学到的关于 Eclipse 或编程的一切都让我成为了一个更强大的程序员 :)

Thanks, Kit谢谢,套件

Use the shortcut ctrl+shft+o in Eclipse.在 Eclipse 中使用快捷键 ctrl+shft+o。 It automatically imports whatever classes needed and suggests you with possible imports if conflict occurs.它会自动导入所需的任何类,并在发生冲突时向您建议可能的导入。

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

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