Here you can find the source of generateRandomLongitude()
public static double generateRandomLongitude()
//package com.java2s; //License from project: Open Source License public class Main { private static final int MIN_LONG = -180; private static final int MAX_LONG = 180; /**//from w w w. j a v a 2 s . c om * * @return random longitude within min and max constraints */ public static double generateRandomLongitude() { return MIN_LONG + (double) (Math.random() * ((MAX_LONG - MIN_LONG) + 1)); } }