题目内容
定义布尔类型和字符串类型的变量,为它们赋值,并打印输出。
- 任务
- 定义一个布尔类型的变量flag,赋值为true,并输出
- 定义一个字符串类型的变量str,值为"hello world",并输出
- 定义一个字符串类型的变量str1,值为空串4、将str的值赋值给str1,并输出
public class StringDemo {
public static void main(String[] args){
//define a bool-type variable which is true and print it
boolean flag = true;
System.out.println("flag=" + flag);
//define a string-type varible which is "hello world" and print it
String str = "hello world";
System.out.println("str=" + str);
//define a string-type varible which is nullstr, copy the value of str and print str1
String str1 = "";
str1 = str;
System.out.println("str1=" + str1);
}
}