File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Range related 2

 
achayya matta
Ranch Hand
Posts: 111
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class JJF4 {
public static void main(String args[]) {

System.out.print(Long.toHexString(Character.MAX_VALUE)+",");
}}

can anyone explain me how the above code is printing "ffff" when run?
using jdk 1.4.2_03
thanks in advance
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you familiar with hexadecimal representation of numbers? If not, there is a wealth of information available via Google. If you are familiar with it, what confusion do you have about the code?
 
Cheenu Subramanian
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Steve said , get ur self acquainted with the hexadecimal representation.

Fyi,

Character.MAX_VALUE when represented as int is 65535 which is represented as ffff in hexadecimal
 
Tilo Hemp
Ranch Hand
Posts: 91
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the missing "," is strange. I think, the ouptut should be "ffff,".
 
Mandy Hou
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
char is unsigned prim
so the rang is 0-62235
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic