Number Class
1. What It Is (beginner)
Number = abstract parent of all numeric wrappers (Integer, Double, Long, ...). Lets you treat any number uniformly: pass Integer or Double where Number expected, then ask .intValue() / .doubleValue().
Number (abstract)
├── Integer, Long, Short, Byte (integers)
└── Double, Float (decimals) + BigInteger/BigDecimal
4. Traps
Numberis abstract:new Number()ERROR (use concreteIntegeretc.)..intValue()onDouble(3.99)cuts → 3 (narrowing!).instanceofto check kind:if (n instanceof Integer)before int-only ops.
5. Exam Points
- Hierarchy +
doubleValueprogram — 3-5 marks, frequent. - Abstract (no
new) + conversion cut — 2-3 marks.