How can a Java variable be different from itself?

前端 未结 10 1868
日久生厌
日久生厌 2020-11-29 16:14

I am wondering if this question can be solved in Java (I\'m new to the language). This is the code:

class Condition {
    // you can change in the main
    p         


        
10条回答
  •  孤街浪徒
    2020-11-29 17:01

    Using the same skip/change output approach from another answers:

    class Condition {
        public static void main(String[] args) {
            try {
                int x = 1 / 0;
                if (x == x) {
                    System.out.println("Ok");
                } else {
                    System.out.println("Not ok");
                }
            } catch (Exception e) {
                System.out.println("Not ok");
            }
        }
    }
    

提交回复
热议问题