Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 1 | // Copyright (c) 2016, the R8 project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | package ifstatements; |
| 5 | |
| 6 | class IfStatements { |
| 7 | |
| 8 | public static void ifNull(Object a) { |
| 9 | if (a != null) { |
| 10 | System.out.println("sisnotnull"); |
| 11 | } |
| 12 | if (a == null) { |
| 13 | System.out.println("sisnull"); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | public static void ifCond(int x) { |
| 18 | if (x == 0) { |
| 19 | System.out.println("ifCond x == 0"); |
| 20 | } |
| 21 | if (x != 0) { |
| 22 | System.out.println("ifCond x != 0"); |
| 23 | } |
| 24 | if (x < 0) { |
| 25 | System.out.println("ifCond x < 0"); |
| 26 | } |
| 27 | if (x >= 0) { |
| 28 | System.out.println("ifCond x >= 0"); |
| 29 | } |
| 30 | if (x > 0) { |
| 31 | System.out.println("ifCond x > 0"); |
| 32 | } |
| 33 | if (x <= 0) { |
| 34 | System.out.println("ifCond x <= 0"); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | public static void ifIcmp(int x, int y) { |
| 39 | if (x == y) { |
| 40 | System.out.println("ifIcmp x == y"); |
| 41 | } |
| 42 | if (x != y) { |
| 43 | System.out.println("ifIcmp x != y"); |
| 44 | } |
| 45 | if (x < y) { |
| 46 | System.out.println("ifIcmp x < y"); |
| 47 | } |
| 48 | if (x >= y) { |
| 49 | System.out.println("ifIcmp x >= y"); |
| 50 | } |
| 51 | if (x > y) { |
| 52 | System.out.println("ifIcmp x > y"); |
| 53 | } |
| 54 | if (x <= y) { |
| 55 | System.out.println("ifIcmp x <= y"); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | public static void ifAcmp(Object a, Object b) { |
| 60 | if (a == b) { |
| 61 | System.out.println("ifAcmp a == b"); |
| 62 | } |
| 63 | if (a != b) { |
| 64 | System.out.println("ifAcmp a != b"); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | public static void main(String[] args) { |
| 69 | Object a = new Object(); |
| 70 | ifNull(a); |
| 71 | ifNull(null); |
| 72 | ifCond(-1); |
| 73 | ifCond(0); |
| 74 | ifCond(1); |
| 75 | ifIcmp(-1, 1); |
| 76 | ifIcmp(0, 0); |
| 77 | ifIcmp(1, -1); |
| 78 | ifAcmp(a, a); |
| 79 | ifAcmp(a, null); |
| 80 | } |
| 81 | } |