what is Java Variable and Data type

Java Variable
A variable is a named storage location in computer memory that holds a data value, which can be modified during program execution. It serves as a symbolic representation for data, allowing programmers to manipulate and reference values within their code. Variables have a data type, such as integers, floating-point numbers, characters, or custom objects, which defines the type of data they can hold.

Variable Data Types in Java
In Java, data types specify the types of values that can be stored in variables. There are two categories of data types:
1. Primitive Data Types: These are the basic data types built into the Java language. They include:
- `boolean`: Represents true or false values.
- `char`: Represents single characters.
- `byte`, `short`, `int`, `long`: Represents integers of varying sizes.
- `float`, `double`: Represents floating-point numbers.
2. Reference Data Types: These data types are references to objects in memory. They include:
- Classes
- Interfaces
- Arrays
Java also provides the ability to create custom data types through classes and interfaces, which are considered reference data types.
Data Type-- | Default Value-- | Memory Size-- | Width-- | Range-- |
---|---|---|---|---|
boolean | false | 1 bit | -- | true or false |
char | '\u0000' | 2 bytes | 16-bit | Unicode characters (0 to 65,535) |
byte | 0 | 1 byte | 8-bit | -128 to 127 |
short | 0 | 2 bytes | 16-bit | -32,768 to 32,767 |
int | 0 | 4 bytes | 32-bit | -2,147,483,648 to 2,147,483,647 |
long | 0L | 8 bytes | 64-bit | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
float | 0.0f | 4 bytes | 32-bit | ±1.4e-45 to ±3.4e38 |
double | 0.0d | 8 bytes | 64-bit | ±4.9e-324 to ±1.7e308 |

Sandipan Kr Bag
I'm a dedicated full-stack developer, entrepreneur, and the proud owner of ocec.org.in , hailing from the vibrant country of India. My passion lies in creating informative tutorials and sharing valuable tips that empower fellow artisans in their journey. With a deep-rooted love for technology, I've been an ardent enthusiast of PHP, Laravel, Angular, Vue, Node, JavaScript, jQuery, Codeigniter, and Bootstrap from their earliest days. My philosophy revolves around the values of hard work and unwavering consistency, driving me to continuously explore, create, and share my knowledge with the tech community.
* Hire MeRelated Posts

জাভাস্ক্রিপ্ট কি? এটি কেন ব্যবহার করা হয় ?

জাভাস্ক্রিপ্ট লেখার পদ্ধতি
Step-by-Step Guide a Dynamic Image Slider with HTML, CSS, and JavaScript
Search
Latest Posts
Using AOS (Animate On Scroll) in React with Tailwind CSS
1 month ago

WebkitSpeechRecognition API
2 months ago

GitHub Understanding Common Prefixes in Conventional Commits
2 months ago
Subscribe to Our Newsletter
Get the latest updates straight to your inbox.