Skip to Main Content
Java™ Puzzlers: Traps, Pitfalls, and Corner Cases
book

Java™ Puzzlers: Traps, Pitfalls, and Corner Cases

by Joshua Bloch, Neal Gafter
June 2005
Beginner to intermediate content levelBeginner to intermediate
312 pages
6h 24m
English
Addison-Wesley Professional
Content preview from Java™ Puzzlers: Traps, Pitfalls, and Corner Cases

7. Library Puzzlers

The puzzles in this chapter concern basic library-related topics, such as Object methods, collections, Date, and Calendar.

Puzzle 56: Big Problem

As a warm-up, test your knowledge of BigInteger. What does this program print?

import java.math.BigInteger;public class BigProblem {    public static void main(String[ ] args) {        BigInteger fiveThousand  = new BigInteger("5000");        BigInteger fiftyThousand = new BigInteger("50000");        BigInteger fiveHundredThousand                                 = new BigInteger("500000");        BigInteger total = BigInteger.ZERO;        total.add(fiveThousand);        total.add(fiftyThousand);        total.add(fiveHundredThousand);        System.out.println(total);    }}

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

A Common-Sense Guide to Data Structures and Algorithms, Second Edition, 2nd Edition

A Common-Sense Guide to Data Structures and Algorithms, Second Edition, 2nd Edition

Jay Wengrow
Algorithms, 4th Edition

Algorithms, 4th Edition

Robert Sedgewick, Kevin Wayne

Publisher Resources

ISBN: 032133678XPurchase book