Section 8: Fundamental Classes in the java.lang Package ( Chapter 10 )

  • Write code using the following methods of the java.lang.Math class: abs, ceil, floor, max, min, random, round, sin, cos, tan, sqrt.

  • Describe the significance of the immutability of String objects.

  • Describe the significance of wrapper classes, including making appropriate selections in the wrapper classes to suit specified behavior requirements, stating the result of executing a fragment of code that includes an instance of one of the wrapper classes, and writing code using the following methods of the wrapper classes (e.g., Integer, Double, etc.):

    • doubleValue

    • floatValue

    • intValue

    • longValue

    • parseXxx

    • getXxx

    • toString

    • toHexString

Study Notes

The java.lang.Math class defines many useful mathematical functions, whose purpose should be understood. Argument type, result type, and the effect of applying each of these functions should be known.

Strings are immutable objects, that is, their contents cannot be changed. String manipulation operations in the String class return new String objects as the result of the operation. The indexing of characters used by string operations is important.

StringBuffer implements a mutable sequence of characters. Most string buffer operations manipulate the character sequence directly. There is no inheritance relationship between the classes String and StringBuffer, and objects of these classes cannot be compared directly.

Each primitive data type has a corresponding wrapper class that allows you to create immutable objects that represent primitive values. The methods toString() and typeValue() can be called on wrapper objects to convert their value to a string or primitive values, respectively. The static wrapper class methods parseType() and valueOf() convert a string to a primitive value or wrapper object, respectively. The static method getType() in the Integer and Long classes can be used to determine values of system properties by name. The static method toHexString() can be used to create a string representation of an int or a long in the hexadecimal notation.



     
    ASPTreeView.com
     
    Evaluation has САЙ·Ѕexpired.
    Info...