Home >Java >javaTutorial >How to implement linear search in java
public class T05 { public static void main(String[] args) { int[]arr=new int[]{1,2,3,4,5,6,7,8,9}; for(int i=0;i< arr.length;i++){ System.out.print(arr[i]+"\t"); } System.out.println(); for(int i=0;i< arr.length;i++){ if(i< arr.length-1-i){ int a=arr[i]; arr[i]=arr[arr.length-1-i]; arr[arr.length-1-i]=a; } } for(int i=0;i< arr.length;i++){ System.out.print(arr[i]+"\t"); } } }
The above is the detailed content of How to implement linear search in java. For more information, please follow other related articles on the PHP Chinese website!