java 声明并初始化字符串变量
public class Sample { public static void main(String[] args) { String str = "Hello world"; System.out.println("String is: " + str); String str2 = new String("Welcome to java"); System.out.println("The second string is: " + str2); } } OUTPUT: String is Hello world The second string is: Welcome to java