1. Home
  2. Computing & Technology
  3. Java
photo of Paul Leahy
Paul's Java Blog

By Paul Leahy, About.com Guide to Java

Monday's Programming Question

Monday December 1, 2008

I had a couple of conversations around literals last week. Which leads me to this week's programming question. In Java, I can use a hexadecimal literal to assign a value to an int variable, like so:

int hexNumber = 0xEF;

and do the same using an octal literal:

int octalNumber = 0647;

The question is, can you write a for loop using hexadecimal and octal literals? More specifically can you write one that starts the iteration variable at 0xEF and stops looping once it equals the value 0647? And, how many times will the for loop go around?

Comments

No comments yet. Leave a Comment

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

Explore Java
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Java

©2009 About.com, a part of The New York Times Company.

All rights reserved.