random Longitude - Android Map

Android examples for Map:Location

Description

random Longitude

Demo Code


//package com.java2s;

import java.util.Random;

public class Main {
    public static Double randomLong(Random rand) {
        return doubleRandomInclusive(-180.0, 180.0, rand);
    }/*from www.j av  a  2 s.c  o  m*/

    public static Double doubleRandomInclusive(double min, double max,
            Random rand) {
        double num = rand.nextDouble();
        if (num < 0.5) {
            return ((1 - rand.nextDouble()) * (max - min) + min);
        }
        return (rand.nextDouble() * (max - min) + min);
    }
}

Related Tutorials