March 2014
Intermediate to advanced
1200 pages
31h 17m
English
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; ...
Read now
Unlock full access