#CoreJava/DataTypesAndVariables

Memory (Unit) - Bit, Byte
programming space doesn't used.

int price = 35000;
String brand = "hp";

Leftside
(int, tring) --> Datatype
(price, brand) --> Identifiers/ Reference Variable

= -->Assign or Assignment operator
Rightside
(35000, "hp") --> Value

; --> End of statement

C,C++, Java --> Statically Typed Programming Language
Python, JavaScript --> Dynamically Typed Programming Language

Variables

Variable Declaration Syntax (Single Variable)

data_type variableName = value;
(ex: int number =10;)

Multiple variables of the same data type

data_type variableName1 = value1, variableName2 = value2;
(ex: String firstName="Arunkumar", lastName = "Selvam";)

Syntax of Variable Declaration & Initialization

data_type variableName; (Variable Declaration)

data_type variaableName = value; (Variable Initialization)

Example:

String userName; // Variable Declaration
String userName = "Arunkumar"; //Variable Initialization
Points to Remember While Using Variables:
Variable Naming Convention
Types of Variables

Data Types in Java

Note

These are reserved keywords in java.

Data Types in Java.png

1 Byte = 8 Bit

1 bit - binary
digit - 0,1s

base2 - 0,1 (Computer Usage)
base8 - 01234567
base10 - 0123456789 (Human Usage)
base16 - 0123456789ABCDEF

28 = 256 = 256/2 = -128 to -1 0 1 to 127 - byte

Datatype - Size, type of date store

Data Type
Size (Bytes)
Maxi and Mini Value Stored
Default Value
Byte
1
-128 to 127 0
Short
2
-32,768 to 32,767 0
Int
4
-2,147,483,648 (-231) to 2,147,483,647 (231-1). 0
Long
8
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 0L
Float
4
6 to 7 decimal point 0.0f
Double
8
15 decimal point 0.0d
Char
2
single character/letter or ASCII values is -128 to 127 '\u0000'
Boolean
1
true or false values false

Bit - Binary Digit - 0, 1s

Base 2 - 0, 1

Base 8 - 01234567

Base 10 - 0123456789

Base 16 - 0123456789ABCDEF

ASCII - American Standard for Code Information Interchange

In Java, the default data type for numbers is "int".

Q&A

What is Variable?

?

Why should learning Datatypes?

?

What is data manipulation?

?

What is Data Types?

?

What is a statically typed language, and can you give an example? (or) Why is Java considered a statically typed language?

?

Dynamically Typed Languages

?

Difference Between Statically Typed Languages and Dynamically Typed Languages

?
DataTypes and Variables - Obsidian Files - Obsidian v1.6.7 12-09-2024 20_28_35.png

What is Primitive Data Types?

?

What is Non-Primitive Data Types?

?

What is Wrapper Class?

?

What is auto-boxing?

?

What is unboxing?

?

What is Unicode?
?