The maximum value occupied by float data type in Java

Java Data_Types How To Use With Examples
Java Data_Types How To Use With Examples


Java Data_Types How To Use With Examples

Data-Types: A java Data type specifies the different sizes and values that can be stored in the variable. There are two types of data types in Java Language. 


Primitive data types: Primitive data types in java boolean Data Types, char Data Types, byte Data Types, short Data Types, int Data Types, long Data Types, float Data Types, and double Data Types.


Non-primitive data types: A non-primitive data types include Classes, Interfaces, and Arrays.


Java Non-Primitive Data Types


Classes


Interface


Array


 

Primitive data types: Primitive data types in java boolean Data Types, char Data Types, byte Data Types, short Data Types, int Data Types, long Data Types, float Data.


 
Types of Primitive Data Types in Java 


1. boolean data type

2. byte data type

3. char data type

4. short data type

5. int data type

6. long data type

7. float data type

8. double data type

Data Types  Default Value   Default Size


boolean             false             1bit


char             '\u0000'      2 byte


byte                      0              1 byte


short                0              2 byte


int                          0            4 byte


long                     0L         8 byte


float                 0.0f            4 byte


double                 0.0d             8 byte



Boolean Data Type: The Boolean knowledge kind is employed to store solely 2 potential values.True and False. 


This knowledge kind is employed for easy flags that track true/false conditions.


The Boolean knowledge kind specifies one little bit of info, however, its "size" cannot be outlined exactly.


Important Same Other Languages Data_Types

👉C++ Data Types

👉C Data Types 

👉Python Data Types


How To Use Boolean Data Types in Java?


public class BooleanExample1 


{    


public static void main(String[] args)


{  


int a=10;  


int b=20;  

          

boolean b1=true;  


boolean b2=false;  

  

if(a<b)  


{  


System.out.println("condition is:"+b1);  


}  


else  


{  


System.out.println("condition is:"+b2);  


}  


}         


}  


*****OUTPUT*****


Compile by: javac BooleanExample1.java


Run by: java BooleanExample1


condition is: true



Byte data Types: A byte data type is a Java primitive data type. 


It is an 8-bit signed two's complement integer. Its value range lies between -128 to 127. 


Its minimum value is -128 and its maximum value is 127. Its default value is 0.



How To Use Byte Data Types in Java?


public class ByteExample1 


{


public static void main(String[] args) 


{


byte a=-128;

byte b=-127;


System.out.println("Minimum Value in Byte:"+a);


System.out.println("Maximum Value in Byte:"+b);


}

}


*****OUTPUT*****


Compile by: javac ByteExample1.java


Run by: java ByteExample1


Minimum Value in Byte:-128


Maximum Value in Byte:-127



Short Data Types: A short data type is a 16-bit signed two's complement integer. 


Its value-range lies between -32,768 to 32,767. It is minimum value is -32,768 and maximum value is 32,767.Its default value is 0.



How To Use Short Data Types in Java?


public class ShortExample1  


 

public static void main(String args[]) 


{

  

short a=-10;  


short b=10;  


System.out.println("Minimum value in short Data Types:"+a);  


System.out.println("Minimum value in short Data Types: "+b);  


}

  

}  


*****OUTPUT*****


Compile by: javac ShortExample1.java


Run by: java ShortExample1



The minimum value in short Data Types:-10


The maximum value in short Data Types:10



Int Data Types: A int data type is a 32-bit signed two complement integer values. It is value-range lies between - 2,147,483,648 to 2,147,483,647. Its minimum value is - 2,147,483,648 and maximum value is  2,147,483,647. It is default value is 0.


 
How To Use int Data Types in Java?


public class intExample1

  

{  


public static void main(String args[])  


{  


int a=-1000;  


int b=1000;  


System.out.println("Minimum value in int Data Types:"+a);  


System.out.println("Minimum value in int Data Types: "+b);  


}  


}  


*****OUTPUT*****


Compile by: javac intExample1.java


Run by: java intExample1


The minimum value in int Data Types:-1000


The maximum value in int Data Types:1000


 

Long Data Type: A long data type is a 64-bit two's complement integer. Its value-range lies between -9,223,372 to 9,223,372. Its minimum value is - 9,223,372 and maximum value is 9,223,372. Its default value is 0. 




How To Use Long Data Types in Java?


public class LongExample1  


{  


public static void main(String args[])  


{  


Long a=-100000L;  


Long b=100000L;  


System.out.println("Minimum value in Long Data Types:"+a);  


System.out.println("Minimum value in Long Data Types: "+b);  


}  


}  

*****OUTPUT*****


Compile by: javac LongExample1.java


Run by: java LongExample1


The minimum value in Long Data Types:-100000


The maximum value in Long Data Types:100000

 

Float Data Types: Afloat data type is a single-precision 32-bit floating-point. Its value range is unlimited. It is recommended to use a float instead of double if you need to save memory in large arrays of floating-point numbers. 



How To Use float Data Types in Java?


public class FloatExample1  


{  


public static void main(String args[])  


{  


float a=64.65f;  

  

System.out.println("Value of Float Data Types:"+a);  

  

}  


}  

*****OUTPUT*****


Compile by: javac FloatExample1.java


Run by: java FloatExample1


Value of Float Data Types:64.65f



Double Data Type: The double data type is a double-precision 64-bit  floating-point. Its value range is unlimited. The double data type is generally used for decimal values just like float. It is default value is 0.0d.



How To Use Double Data Types in Java?


public class DoubleExample1  


{  


public static void main(String args[])  


{  


double a=614.65d;  

  

System.out.println("Value of Double Data Types:"+a);  

  

}  


}  


*****OUTPUT*****


Compile by:javac DoubleExample1.java


Run by: java DoubleExample1


Value of Double Data Types:614.65d



Char Data Types: A char data type is a single 16-bit Unicode character. Its value- range lies between '\u0000' The char data type is used to store characters.



How To Use Char Data Types in Java?


public class CharExample1  


{  


public static void main(String args[])  


{  


char gender='M';  

  

System.out.println("Value of Char Data Types:"+gender);  


  

}  


}  


*****OUTPUT*****


Compile by: javac CharExample1.java


Run by: java CharExample1


Value of Char Data Types: M



Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.