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("没找到!"); } } }