Data types in Java
Data types specifies the types of value and its size that can be stored in an identifier. There are 2 types of data types as given below.
- Primitive data types
- Non-Primitive/Reference data types
Datatype | Description | Example | Default value |
byte | Can be used for saving memory in large arrays.It is four times smaller than an int. |
byte a =100 | 0 |
short | Can be used for saving memory in large arrays.It is two times smaller than an int. |
short x=1000 | 0 |
int | int is generally use as default data type,unless there is memory concern | int x=1000 | 0 |
long | It is used when larger value than int is needed. | int x=100000L | 0L |
float | use it if needs to save memory in large arrays of floating point numbers. | int x=176.8f | 0.0f |
double | It is generally used as default value for decimal values. | int d=176.8 | 0.0d |
boolean | Its 2 possible value are – true and false. | boolean name=true | false |
char | Char data type is used to store any character. | char c =”A” | ‘\u0000’ |
Ask Question
If you have any question, you can to go menu ‘Features -> Q&A forum-> Ask Question’.Select the desired category and post your question.
1 Response
[…] We will take the example of a Webtable present in the the ‘www.testingpool.com‘. You can access this webtable at “https://testingpool.com/data-types-in-java/“. […]