How to cite a web site - 1174 Java Utilities Package and Bit Manipulation Chapter
1174 Java Utilities Package and Bit Manipulation Chapter 20 Testing and Debugging Tip 20.2 Use Properties method list to display the contents of a Properties object for debugging purposes. Line 181 calls Properties method load to restore the contents of the Properties object from the InputStream specified as the first argument (in this case, a FileInputStream). Line 208 calls Properties method propertyNames to obtain an Enumeration of the property names. The value of each property can be determined by using method getProperty. 20.7 Random Class We discussed random-number generation in Chapter 6, Methods, where we used Math class method random. Java provides extensive additional random number generation capabilities in class Random. We briefly walk through the API calls here. A new random-number generator can be created by using Random r = new Random(); This form uses the computer s current time to seed its random-number generator differently during each constructor call and thus generates different sequences of random numbers for each Random object. To create a pseudorandom-number generator with repeatability, use Random r = new Random( seedValue ); The seedValue argument (type long) is used in the random number calculation to seed the random number generator. If the same seedValue is used every time, the Random object produces the same sequence of random numbers. Testing and Debugging Tip 20.3 While a program is under development, use the form Random(seedValue) that produces a repeatable sequence of random numbers. If a bug occurs, fix the bug and test with the same seedValue; this allows you to reconstruct the exact same sequence of random numbers that caused the bug. Once the bugs have been removed, use the form Random(), which generates a new sequence of random numbers each time the program is run. The call r.setSeed( seedValue ); resets r s seed value at any time. The calls r.nextInt() r.nextLong() generate uniformly distributed random integers. You can use Math.abs to take the absolute value of the number produced by nextInt, thus giving a number in the range from zero through approximately 2 billion. Then use the % operator to scale the number. For example, to roll a six-sided die, if you scale with a 6, you will get a number in the range from
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision web and email hosting services