当我运行一些代码(稍后会展示),我告诉它检查字符串是否等于“1”,如果是,输出“It's 1!”,否则输出该字符串。
代码: ```python if string == "1": print("It's 1!") else: print(string) ```
代码: ```python if string == "1": print("It's 1!") else: print(string) ```
double shirt3 = Math.random() * 9;
String shirt2 = Double.toString(shirt3);
char shirt1 = shirt2.charAt(0);
String shirt = Character.toString(shirt1);
if(shirt == "1") {
System.out.println("It's 1!");
} else {
System.out.println(shirt);
}
输出:
7
4
8
1
7
1
7
7
6
0