equals的应用

package com.atguigu.java;

public class ArrayTest2 {
    
    public static void main(String[] args){
        
        String[] arr1 = {"aa","bb","cc","dd"};
        
        /*for(int i = 0;i <= (arr1.length-1)/2;i++){
            String temp = "";
            temp = arr1[i];
            arr1[i] = arr1[arr1.length-i-1];
            arr1[arr1.length-i-1] = temp;
        }*/
        
        boolean isFlag = true;
        String dest = "cc";
        
        for(int i = 0;i < arr1.length;i++){
            if(dest.equals(arr1[i])){                             //equals的应用;
                System.out.println("找到了,位置为:" + i);
                isFlag = false;
            }
        }
        if(isFlag == true){
            System.out.println("没找到!");
        }
        
    }
        
}

 

上一篇:百度地图获取搜索后获取选中标注的名称、地址、坐标等信息


下一篇:来 BB 几句!