# (Solved) Implement a Java program that finds two neighboring numbers in an array with the smallest distance to each other

Implement a Java program that finds two neighboring numbers in an array with the smallest distance to each other. The function should return the index of the first number. In the sequence 4 8 6 1 2 9 4 the minimum distance is 1 (between 1 and 2). The function should return the index of number 1 which is 3. For each array element take user input to form the array. Hint: Use Math.abs() to calculate the distance of two numbers. Math.abs() is used to give you the absolute value. For example the difference between 1 and 2 is 1-2 = -1. If you use Math.abs(1-2) it will give you 1 instead of -1.

Sample Run:

Enter the size of the array: 7

Please enter 7 positive integers: 4 8 6 1 2 9 4

The minimum difference is 1 and the numbers are 1 and 2. The index of 1 is 3.

## Best Solution

In the sequence 4 8 6 1 2 9 4 the minimum distance is 1 (between 1 and 2). The function should return the index 3 (of number 1).class LangFund3{
static void smallestDistance(int [] array){…………..

OR  