Home > Java > javaTutorial > How to implement linear search in java

How to implement linear search in java

WBOY
Release: 2023-04-24 18:28:15
forward
936 people have browsed it

Linear Search

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");
        }
    }
}
Copy after login

How to implement linear search in java

How to implement linear search in java

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template