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

 

posted @ 2019-12-19 09:35  anobscureretreat  阅读(3014)  评论(0编辑  收藏  举报