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

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Example to show double exception in java 
 

The Tutorial describe you a code from double exception in java.

 

Example to show double exception in java

                         

The Tutorial describe you a code from double exception in java. The given below program tells about the occurrence of double exception. Double is a class that wraps a value of the primitive type double in an object. Double exception occurs in java when the string or primitive data type are not converted into a double value. The step involved in a program are described below - 

1)We have a class Double Exception, that include a main method. The main method include  -

Buffered Reader-  This read the text from the character stream

read line  ( ) - This is used to read a line of text.

to string( )  - This object  return you a string irrespective of any type of data type.

In case a user try to enter a string or primitive data type, that is not converted into a double, this causes the try block to cause exception in a code The exception subsequently handled by a catch block and show you a user defined message in the println.

Doubleexception.java


import java.lang.Math.*;

public class Doubleexception {

    public static void main(String args[]) {
        double c = 0;
        try {
            Double d = (500 100.9;
            c = d.intValue();
        catch (Exception e) {
            System.out.println(e.getMessage());
        }
        System.out.println("Value of c is: "+c);
    }
}

Output of the program

Value of c is: 4.0

Note:-if you will pass any number other than double type program will generate exception.

Download sourcr code

                         

» View all related tutorials
Related Tags: c exception io stack type exec uri lock this block exe row handle program to execution ram each pos ast

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
Software Solutions
Least Viewed
Most Rated
Recently Viewed
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.