Here you can find the source of manhattanDistance(Point a, Point b)
public static int manhattanDistance(Point a, Point b)
//package com.java2s; //License from project: Open Source License import java.awt.Point; public class Main { /**/*from w ww. j ava 2 s . co m*/ * Calculate manhattan distance between two locations. */ public static int manhattanDistance(Point a, Point b) { return Math.abs(a.x - b.x) + Math.abs(a.y - b.y); } }