Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Can't believe I need to write this myself, but I guess
     * it's just 7 lines of code and infinitely more trustworthy
     * than that java.Arrays.binarySearch crap.
     * TODO this probably should go into some sort of kUtil class
     */
    public static int arrayLinearSearch(Object[] a, Object s) {
        for (int i = 0; i < a.length; i++) {
            if (s.equals(a[i]))
                return i;
        }
        return -1;
    }
}