객체 안에서 많은 원시 타입을 감싸기 위하여 wrapper 클래스들 – Byte
, Double
, Float
, Integer
, Long
, 또는 Short
– 중 하나를 사용합니다. 자바 컴파일러는 필요할 때 그리고 그들을 언박스 할 때 자동으로 원시들을 wraps (boxes) 합니다.
You use one of the wrapper classes – Byte
, Double
, Float
, Integer
, Long
, or Short
– to wrap a number of primitive type in an object. The Java compiler automatically wraps (boxes) primitives for you when necessary and unboxes them, again when necessary.
The Number
classes include constants and useful class methods. The MIN_VALUE
and MAX_VALUE
constants contain the smallest and largest values that can be contained by an object of that type. The byteValue
, shortValue
, and similar methods convert one numeric type to another. The valueOf
method converts a string to a number, and the toString
method converts a number to a string.
To format a string containing numbers for output, you can use the printf()
or format()
methods in the PrintStream
class. Alternatively, you can use the NumberFormat
class to customize numerical formats using patterns.
The Math
class contains a variety of class methods for performing mathematical functions, including exponential, logarithmic, and trigonometric methods. Math
also includes basic arithmetic functions, such as absolute value and rounding, and a method, random()
, for generating random numbers.
'Java 배우기' 카테고리의 다른 글
Characters 글자 (0) | 2016.01.05 |
---|---|
Questions and Exercises: Numbers 질문과 연습: 숫자 (0) | 2016.01.05 |
Beyond Basic Arithmetic 기본 산술을 넘어서 (0) | 2016.01.05 |
Formatting Numeric Print Output (0) | 2016.01.05 |
The Numbers Classes 숫자 클래스들 (0) | 2016.01.05 |
댓글