Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Wrapper-class Convert an Integer type object to a String object

Related Tutorials


 
 

Share on Google+Share on Google+

Convert an Integer type object to a String object

Advertisement
In this section you will learn to convert the Integer type object to a String object using the Integer.toBinaryString() and Integer.toHexString() methods.

Convert an Integer type object to a String object

     

In this section you will learn to convert the Integer type object to a String object using the Integer.toBinaryString() and Integer.toHexString() methods.

Here is an example that provides the usage of the
Integer.toBinaryString() and Integer.toHexString() method in more detail. 

Create a class "NumberFormats" where an integer type object is converted into a string of binary type using the Integer.toBinaryString() and again to a hex type string using the Integer.toHexString() type method.

Here is the Code of the Example :

NumberFormats.java:

import java.util.*;
public class NumberFormats{
  public static void main(String argv[]){
  System.out.println(Integer.toBinaryString(4));
  System.out.println(Integer.toHexString(16));

  }
}

Here is the Output of the Example :

C:\roseindia>javac NumberFormats.java

C:\roseindia>java NumberFormats
100
10

C:\roseindia>
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 28, 2008

Related Tutorials

Discuss: Convert an Integer type object to a String object  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com