Share on Google+Share on Google+

String valueOf()

This page discusses - String valueOf()

String valueOf()


In this section, you will get the detailed explanation about the valueOf() method of String class. We are going to use valueOf() method of String class in Java. The description of the code is given below for the usage of the method.

Description of the code:

This method creates a new String object containing the string representation of a double, float, short, byte, integer, long etc. As shown in the program code below taken strings of different types as long, short, integer, byte etc and then we have applied the valueOf() method to get a string object. The representation is exactly the one returned by the Double.toString(), Long.tostring(), Short.toString(), Float.toString() method of one argument etc.

Here is the code of the program: 

public class strvalueOf{
  public static void main(String args[]) {
  Integer i = Integer.valueOf("862");
  Long l = Long.valueOf("228693");
  Byte b = Byte.valueOf("55");
  Short s = Short.valueOf("9");
  Float f = Float.valueOf("852.256");
  Double d = Double.valueOf("259873.147369222");

Output of the program:


C:\unique>java strvalueOf


Download this example.


Posted on: April 17, 2011 If you enjoyed this post then why not add us on Google+? Add us to your Circles

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.

Discuss: String valueOf()  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
April 21, 2013
thank you for informations.

i need a file for learning css& also java. can you help me?