Chapter 8
Exploring the Basic APIs, Part 2
There are more basic APIs in the java.lang package and also in java.lang.ref, java.lang.reflect, and java.util to consider for your Android apps. For example, you can add timers to your games.
Exploring Random
In Chapter 7, I formally introduced you to the java.lang.Math class’s random() method. If you were to investigate this method’s source code from the perspective of Java 7, you would encounter the following implementation:
private static Random randomNumberGenerator; private static synchronized Random initRNG() { Random rnd = randomNumberGenerator; return (rnd == null) ? (randomNumberGenerator = new Random()) : rnd;} public static double random() { Random rnd = randomNumberGenerator; ...
Get Learn Java for Android Development, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.