从零开始学Java (五)条件选择

if
switch
while
do while
for
break
continue

这块对于有语言基础的人来说可以跳过了。

注意有个equals方法。

 1 public class Main {
 2     public static void main(String[] args) {
 3         String s1 = "hello";
 4         String s2 = "HELLO".toLowerCase();
 5         System.out.println(s1);
 6         System.out.println(s2);
 7         if (s1.equals(s2)) {
 8             System.out.println("s1 equals s2");
 9         } else {
10             System.out.println("s1 not equals s2");
11         }
12     }
13 }

猜你喜欢

转载自www.cnblogs.com/gaoshaonian/p/11696657.html
今日推荐