Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials:
 

Software Solutions and Services
 

 
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments
 
Convert String to Number 
 

In this section, we will learn how to convert String to Number.

 

Convert String to Number

                         

In this section, we will learn how to convert String to Number. The following program provides you the functionality to convert String to Number.

Code Description:

In this program we have taken a String of int, byte, boolean, double as shown below and also we have used the method MIN
_VALUE and MAX_VALUE of different wrapper classes to print all the values on int, short, double etc. 

Here is the code of the program:

 

 

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" "\t\t" (byte)"\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);
}
}

Output of the program:

C:\unique>javac StrToNum.java

C:\unique>java StrToNum
Formatable of the Java Numbers
Primitive Type       Size in Bits        Typical Value      Minimum Value   Maximum Value
************** ************** ************** ************** **************
int                           32                          65536                 -2147483648          2147483647
byte                        8                            5                         -128                        127
short                      16                          1024                    -32768                    32767
boolean                                               true,false
double                   64                          1.0E102               4.9E-324               1.79769313486231
57E308
************** ************** ************** *************** ************

C:\unique>

Download this example.

                         

» View all related tutorials
Related Tags: c convert io help this program to learn ram ear e il it section li in converting m ps all

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Website Designing Services
 
Web Designing Packages From $150!
 
Website Designing Company Web Hosting
 
Website Designing Quotation
 
Search Tutorials:

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.