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

Ads
 

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.

View Answers

April 8, 2011 at 3:57 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
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
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
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
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
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
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
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
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   
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
What is the base class of all classes?
What is the base class of all classes?  Hi, What is the base class of all classes? thanks   Hi, The base class is nothing but the Abstract class of Java programming. We uses the syntax for base class of all
Version of drools-examples>drools-examples dependency
List of Version of drools-examples>drools-examples dependency
java.lang.UnsupportedClassVersionError: Bad version number in .class file
java.lang.UnsupportedClassVersionError: Bad version number in .class file  My java servlet not working correctly on my website. I have tried every... java.lang.UnsupportedClassVersionError: Bad version number in .class file
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
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
JAVA Code for Getting List of Directories and its SubDirectories from FTP server
JAVA Code for Getting List of Directories and its SubDirectories from FTP server  **Hi. I am trying to get list of all directories and sub directories and its files from "FTP" and want to show in Jtree but i am unable to do
Squaring of two number in Static class
number . First of all, we have to define class named "StaticSquare"... Squaring of two number in Static class  ... in the class method. We are going to create object for calling the two number
Java Programming Examples
- How to determine largest number from given numbers. List all even numbers...*) example list What is java.util package?   Generating... in Java Many Examples of Java I/O package classes and interfaces
Version of excalibur-component-examples>excalibur-component-examples dependency
List of Version of excalibur-component-examples>excalibur-component-examples dependency
Wrapper Class Tutorial and Examples
Wrapper Class Tutorial and Examples   ... the capacity of a list i.e. retrieving the number of objects contained... will learn about Wrapper classes and all the methods that manipulate
Java NIO Package Tutorial
Java NIO Package Tutorial - Learn and master NIO Package with many examples In this section we will learn about the java.nio package and see how to make.... Example of java.nio package Now we will see examples on java.nio package and how
Multiplication of Two Number in Class
Multiplication of Two Number in Class  ... multiply two number. A class consists of a collection of types of encapsulation... for multiply. First all of we have to define class named "Multiply"
Which class is extended by all other classes?
Which class is extended by all other classes?   Hi, Which class is extended by all other classes? thanks
Example of a class variable (static variable)
you can define the static class variable in a class. When a number of objects are created from the same class, each instance has its own copy of class... of a static variable first of all create a class StaticVariable. Define one static
ModuleNotFoundError: No module named 'list-printer-package'
ModuleNotFoundError: No module named 'list-printer-package'  Hi...: No module named 'list-printer-package' How to remove the ModuleNotFoundError: No module named 'list-printer-package' error? Thanks   Hi
ModuleNotFoundError: No module named 'pip-package-list'
ModuleNotFoundError: No module named 'pip-package-list'  Hi, My... named 'pip-package-list' How to remove the ModuleNotFoundError: No module named 'pip-package-list' error? Thanks   Hi, In your

Ads