Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    private static int findClosest(int[] paramArrayOfInt, int paramInt) {
        int i = 0;
        int j = Math.abs(paramArrayOfInt[0] - paramInt);
        int k = 1;
        while (true) {
            int m = paramArrayOfInt.length;
            if (k >= m)
                break;
            int n = Math.abs(paramArrayOfInt[k] - paramInt);
            if (n < j) {
                j = n;
                i = k;
            }
            k += 1;
        }
        return i;
    }
}