国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

004ConditionalsInjavaJAVA中的條件句

2019-11-14 15:29:13
字體:
來源:轉載
供稿:網友

For example:

//Test004.javapublic class Test004 {    public static void main(String[] args) {        int a =8;        int b =8;        if(a==b){            System.out.);        }        else{            System.out.println("a is not equal to b.");        }        /*         * == and equals         *The Operator == works a bit different on objects than on primitives.          When we are using objects and want to check if they are equal, the          operator == wiil say if they are the same, if you want to check if          they are logically equal, you should use the equals method on the object.          For example:        */        String person_a=new String("gavin");        String person_b=new String("gavin");        String person_c=person_a;        System.out.println(person_a==person_b);//這里會輸因為false,        //因為person_a和person_b不是一個對象,分配的物理空間的地址不一樣        System.out.println(person_a.equals(person_b));//這里會輸出true,        //因為person_a和persion_b的邏輯值一樣,都是gavin        System.out.println(person_a==person_c);//這里會輸出true,        //因為person_a和person_b實際上是同一個對象    }}

 

上述代碼中的第6行中,a=b就是條件句。在java中,條件句返回的結果必須是boolean類型的值。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴文县| 遂川县| 海伦市| SHOW| 独山县| 新干县| 黎川县| 阿拉善左旗| 新密市| 泰和县| 从化市| 萝北县| 平顶山市| 惠水县| 两当县| 乌鲁木齐市| 栾川县| 手游| 梁河县| 石楼县| 佛学| 翁牛特旗| 太仓市| 英吉沙县| 惠东县| 蛟河市| 崇州市| 鄂托克旗| 江山市| 凤凰县| 神木县| 饶阳县| 新巴尔虎左旗| 儋州市| 云阳县| 潼南县| 涡阳县| 巴彦县| 玛沁县| 克什克腾旗| 江城|