View RSS Feed

Java String

Convert String to Number

Rate this Entry
by , 04-26-2012 at 06:57 PM (665 Views)
This section shows how Number is converted into String. Functionaliy is provided by this program for conversion of String into Number,
Code Description:
In this program, String os Boolean, int, byte, double is being taken as it is given below. Also, MIN_VALUE and MIN_VALUE methods are used which are different wrapper classes so that all values on double, short and int could be printed.
Here is the code used:
Java Code:
public class StrToNum{
  public static void main (String args[]){
  String table = "Table of the Java Numbers\n" +
 "Primitive Type\tSize in Bits\tTypical Value\tMinimum Value
\tMaximum Value\n" +
 "**************\t**************\t**************\t**********
****\t**************\n";
  
  // int
  table += "int\t\t" + 32 + "\t\t" + 65536 + "\t\t" + Integer.MIN_VALUE
 + "\t" + Integer.MAX_VALUE + "\n";
  // byte
  table += "byte\t\t" + 8 + "\t\t" + (byte)5 + "\t\t" + Byte.MIN_VALUE 
+ "\t\t" + Byte.MAX_VALUE + "\n";
  // short
  table += "short\t\t" + 16 + "\t\t" + (short)1024 + "\t\t" + Short.MIN_VALUE
 + "\t\t" + Short.MAX_VALUE + "\n";
  //boolean
  table += "boolean\t\t" + "\t\t" + true + ',' + false + "\t\t" + "\n";
  // double
  table += "double\t\t" + 64 + "\t\t" + 100e100 + "\t\t" + Double.MIN_VALUE +
 "\t" + Double.MAX_VALUE + "\n";
  table +=
 "**************\t**************\t**************\t***************\t************\n";

  System.out.println(table);
}
}

Submit "Convert String to Number" to Facebook Submit "Convert String to Number" to Digg Submit "Convert String to Number" to del.icio.us Submit "Convert String to Number" to StumbleUpon Submit "Convert String to Number" to Google

Comments