Code example for Random

Methods: nextDouble

0
        filter.addCategory(Intent.CATEGORY_DEFAULT);
        context.registerReceiver(receiver, filter);
    } 
 
    private static String flipCoin() {
        Random rand = new Random();
        Double flip = rand.nextDouble();
        String result = "";
 
        if (flip < 0.5)
            result = "heads";
        else 
            result = "tails";
 
        return result;
    } 
 
} 
Experience pair programming with AI  Get Codota for Java