x
Loading
 Loading
Hello, Guest | Login | Register

Java Puzzlers

Think you know everything there is to know about Java? Well, here’s your chance to prove it. Java personalities and experts Click and Hack Type-It present a pack of precocious Java puzzlers for your education and entertainment.

puzzelers_01

Josh: Hi. We’re Click and Hack, the Type-it Brothers. Welcome to Code Talk. In today’s special edition of Code Talk, we have a series of Java programming language puzzlers to amuse and abuse you. The problems cover the language and its core libraries, specifically java.lang and java.util. In the first half of the program, we’ll give the problems, and in the second half, the solutions. We suggest you check the answer to each problem before moving on to the next one. And remember, it’s not all fun and games. Each problem also teaches some lesson, and we’ll discuss those with the solutions.

Neal: And for the competitive masochists out there who want to keep score, give yourself one point for each problem you get right, and we’ll grade you in the third half of the program.

Puzzlers One and Two: “Loopers”

Josh: To begin, we’re going to talk about loops.

Neal: What, Froot Loops?

Josh: No you dingbat, while loops! What does this loop do?

 while (i == i + 1); 

Neal: It’s obvious. That loop does nothing. A number is never equal to itself plus one.

Josh: Well, maybe yes, maybe no… What if that line of code is preceded by this:

 double i = 1.0 / 0.0; 

Believe it or not, 1.0/0.0 is legal. Java uses IEEE 754 arithmetic, which lets you store infinity…

Please log in to view this content.

Not Yet a Member?

Register with LinuxMagazine.com and get free access to the entire archive, including:

  • Hands-on Content
  • White Papers
  • Community Features
  • And more.
Already a Member?
Log in!
Username

Password

Remember me

Forgotten your password?
Forgotten your username?
Read More
  1. Helpful Tools for Software Developers
  2. The Github Hall of Fame
  3. Book'em, Github.
  4. This Week on Github: Stupid Ruby Tricks
  5. A Veritable Scatter Shot!
Follow Linux Magazine
Rackspace