Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.

Ads

 
 

Share on Google+Share on Google+

nayani prasangika
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
1 Answer(s)      6 years and 5 months ago
Posted in : Java Magazine

Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.

Ads
View Answers

April 8, 2011 at 3:58 PM


Subclasses of Number class are:

 BigDecimal
 BigInteger
 Byte
 Double
 Float
 Integer
 Long
 Short

Example:

import java.util.*;
class  ScannerExample
{
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter Number: ");
        String st=input.next();
        int intnum=Integer.parseInt(st);
        double doublenum=Double.parseDouble(st);
        double floatnum=Float.parseFloat(st);
        double longnum=Long.parseLong(st);
        double shortnum=Short.parseShort(st);

        System.out.println(intnum);
        System.out.println(doublenum);
        System.out.println(floatnum);
        System.out.println(longnum);
        System.out.println(shortnum);
    }
}

BigInteger Examples

BigDecimal Examples


Ads









Related Tutorials/Questions & Answers:
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Advertisements
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.
Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples.  Discuss the Number Class in the java.lang package & list all its subclasses with appropriate examples
Discuss the Number Class in the java.lang package
Discuss the Number Class in the java.lang package   Discuss the Number Class in the java.lang package
subclasses an imported class - Java Beginners
subclasses an imported class  Sir, Pls help me to write: Program to illustrate subclasses an imported class Thanks
Java Exception Class Hierarchy Diagram
class. The class Exception and its subclasses are defined in such a way... extends the Throwable class. All errors and exception classes are the subclasses... in this class are inherited from its parent class i.e. java.lang.Throwable
How do Unzip a directory and all its contents using ZipEntry class in java.
How do Unzip a directory and all its contents using ZipEntry class in java. In this Example, We will discuss the use isDirectory method of ZipEntry class.... The ZipEntry class is available in java.util.zip package. The isDirectory method
Examples of Wrapper Class
Examples of Wrapper Class In this page we are giving you the links... in the java.lang package. These classes provides object methods for the following... value through add(Object) method. 3.  Append all elements through
Class in Java
; In this section, we will discuss about java classes and its structure. First of all learn:  what is a class in java and then move on to its... a member of the class available to all classes in the same package and all
class with in its own objects?
class with in its own objects?  Is it a good idea to declare a class with in its own objects
Convert Decimal To Character
;  This is the simple program of java.lang package. In this example, we are going to convert decimal number to its corresponding character. Code Description: Here, define class named ?DecimalToChar? for java component
Java Conversion
will learn to convert decimal number into binary. The java.lang package provides... into a hexadecimal number. The package java.lang provides the functionality... number into an integer. The java.lang package provides the functionality to convert
Java Util Examples List
package of JDK. All the examples are with free source code. It includes many examples that demonstrate the syntax and example code of java util package... Java Util Examples List - Util Tutorials   
write a program to demonstrate wrapper class and its methods......
write a program to demonstrate wrapper class and its methods......  write a program to demonstrate wrapper class and its methods
why java file save as its class name
why java file save as its class name  hi,this is subbareddy vajrala.my doubt is why java files save as its class names
PHP list class methods
Function get_class_methods gives the all methods names of the given class. It takes input as class name and returns the array of the methods name PHP LIst Class Methods Example <?php class myclass{ function aa
List control class
List control class  Hi... What Class does all list base controls extend? and implement? please give me the name of these classes..... Tnanks   Ans: All list based control extend the ListBase class and implement
Difference in size of .java & its respective .class file
Difference in size of .java & its respective .class file  Hai, I had created & compiled a java class named sample.java. The size of sample.java is 340KB. Whereas the size of its respective class file sample.class is 137KB
Implement Complex Number Class
Implement Complex Number Class You all are aware of Complex Numbers... are going to implement Complex Number class and perform operations on it. Here is the code: public class ComplexNumber { private int a; private int b
list file number - Java Beginners
list file number  sir you still haven't understand my problem. i have to list out only the number of files in a given directory,your solution still give number of (files+directories) in given directory. are jfilechooser provide
Java program to get class name without package
example which describes you that how you can get the class name without package. For this purpose we have to fetch first the full class name with package.... As a result we will finally get the class name without package.  In this code
Java AWT Package Example
. Many running examples are provided that will help you master AWT package. Example... Components The class component is extended by all the AWT components. More... program uses Arcs2D class, arcs2D is the abstract superclass for all objects
Java Path Class
Java Path Class In this section we will discuss all the aspect of Path class of Java. In Java, Path class is added from the SE 7 release. Java 7 has added the java.nio.file package (new file IO). Prior to JDK7/JRE7 many of the methods
Addition of two Number in Class
method. Class is a cohesive package that consist of a particular values...; we are going to use addition of  two number. First of all, we have... Addition of two Numbers in Class   
which class is super class to all classes
which class is super class to all classes  in java which class is super class to all classes   Object is the super class for all user defined and predefined class.   java.lang.Object is the supper class of all
Version of drools-examples>drools-examples dependency
List of Version of drools-examples>drools-examples dependency
Convert Byte to Hexadecimal
into a hexadecimal number. The package java.lang provides the functionality for this conversion. Code Description: This program takes a byte number from console... it into an integer number. Here is the code of this program import java.io.*; import
class odject in list
class odject in list  I have three class. In first class i have get and set methods, in second class i have a list of objects of first class then after main class i want to read the objects values but it will shows only
PHP list all variables
PHP all declared and environment variables can be listed get_defined_vars() method returns all the variables in the form of array. The array returned is handles by the class ArrayObject class. Example of PHP List of all