对于任何程序,我必须在Java中使用哪些常见的导入?

Ser*_*pia -1 java import

我在NetBeans中创建了一个仅用于字符串操作的类.我应该使用什么进口产品.

我甚至无法声明一个字符串变量,因为它没有为我自动生成导入.:P由于我是新手,我不知道Java世界中的必要性是什么.

这不起作用:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package helloworld;

import java.text;

/**
 *
 * @author Sergio
 */
public class WordManipulations 
{
    public string[] ReturnAllVowels()
    {
        return string[] x;


}
}
Run Code Online (Sandbox Code Playgroud)

它说那个字符串;找不到符号;

cle*_*tus 11

在Java中,它的大写,所以String.

String课程在课程中java.lang.此包会自动导入到每个程序中.

  • @TofuBeer - JLS(7.5.5)说:"每个编译单元自动导入预定义包java.lang中声明的所有公共类型名称......"如果JLS说它们是导入的,那么它们就是导入的. (2认同)

Ign*_*ams 5

Java标识符区分大小写; 你想要的String.此外,不需要进口; java.lang由编译器隐式导入.