Chapter 20 Java Utilities Package and Bit Manipulation (Web server logs)
Saturday, May 5th, 2007Chapter 20 Java Utilities Package and Bit Manipulation 1195 erence to the top element of the stack without removing the element. Stack method emptydetermines whether the stack is empty. A Dictionary transforms keys to values. Hashing is a high-speed scheme for converting keys into unique array subscripts for storage and retrieval of information.The load factor is the ratio of the number of occupied cells in a hash table to the size of the hash table. The closer this ratio gets to 1.0, the greater the chance of collisions. The no-argument Hashtable constructor creates a Hashtable with a default capacity of 101 elements and a default load factor of .75. The Hashtable constructor that takes one argument specifies the initial capacity; the constructor that takes two arguments specifies the initial capacity and load factor, respectively. Hashtable method putadds a key and a value into a Hashtable. Method get locates the value associated with the specified key. Method remove deletes the value associated with the specified key. Method isEmpty determines whether the table is empty. Hashtable method containsKey determines whether the key specified as an argument is in the Hashtable (i.e., a value is associated with that key). Method contains determines whether the Object specified as its argument is in the Hashtable. Method clear empties the Hashtable. Method elements obtains an Enumeration of the values. Method keys obtains an Enumeration of the keys. A Propertiesobject is a persistent Hashtable object. Class Propertiesextends Hash- table. Keys and values in a Properties object must be Strings. The Properties no-argument constructor creates an empty Properties table with no default properties. There is also an overloaded constructor that is passed a reference to a default Properties object containing default property values. Properties method getProperty locates the value of the key specified as an argument. Method store saves the contents of the Properties object to the OutputStream object specified as the first argument. Method load restores the contents of the Properties object from the InputStream object specified as the argument. Method propertyNames obtains an Enumeration of the property names. Java provides extensive random-number generation capabilities in class Random. Class Random s no-argument constructor uses the time to seed its random-number generator differently each time it is called. To create a pseudorandom-number generator with repeatability, use the Random constructor that takes a seed argument. Randommethod setSeed sets the seed. Methods nextIntand nextLong generate uniformly distributed random integers. Methods nextFloatand nextDouble generate uniformly distributed values in the range 0.0 <= x < 1.0. The bitwise AND (&) operator sets each bit in the result to 1 if the corresponding bit in both operands is 1. The bitwise inclusive OR (|) operator sets each bit in the result to 1 if the corresponding bit in either (or both) operand(s) is 1. The bitwise exclusive OR (^) operator sets each bit in the result to 1 if the corresponding bit in exactly one operand is 1. The left shift (<<) operator shifts the bits of its left operand to the left by the number of bits specified in its right operand. The right shift operator with sign extension (>>) shifts the bits in its left operand to the right by the number of bits specified in its right operand if the left operand is negative, 1s are shifted in from the left; otherwise, 0s are shifted in from the left.
Note: If you are looking for best quality webspace to host and run your tomcat application check Vision shared web hosting services