Here you can find the source of minDistance(int[][] colors, int len, int[] color)
public static int minDistance(int[][] colors, int len, int[] color)
//package com.java2s; //License from project: Open Source License public class Main { public static int minDistance(int[][] colors, int len, int[] color) { int smallest = 0; int minDist = 3 * 256; for (int x = 0; x < len; x++) { int dist = Math.abs(color[0] - colors[x][0]) + Math.abs(color[1] - colors[x][1]) + Math.abs(color[2] - colors[x][2]); if (dist < minDist) { minDist = dist;/*from w w w . j av a 2 s . c o m*/ smallest = x; } } return smallest; } }