//基本查找/顺序查找 核心:从0索引开始挨个查找标签:基本,arr,顺序,int,System,number,查找,out From: https://www.cnblogs.com/liuxuefeng/p/17724345.html
//例:查询元素number是否存在
int[] arr = {131, 127, 147, 81, 103, 23, 7, 79};
System.out.println("请输入要查找的数:");
Scanner sc = new Scanner(System.in);
String numberString = sc.nextLine();
int number = Integer.parseInt(numberString);
for (int i = 0; i < arr.length; i++) {
if (arr[i] == number){
System.out.println("存在");
return;
}
}
System.out.println("不存在");