Curriculum
Data Types, Variables, and Operators in Java are fundamental concepts that every Java programmer must understand before building applications. These concepts help developers store data, perform calculations, process information, and control program behavior.
In this Core Java course in Jaipur, students will learn different Java data types, how to declare variables, and how operators work in Java programming. These concepts are essential for software development, backend programming, Android development, and enterprise application development.
Data types in Java define:
Java is a strongly typed programming language, which means every variable must have a defined data type.
Java data types are divided into two categories:
Primitive data types store simple values directly in memory.
| Data Type | Size | Example |
|---|---|---|
| byte | 1 byte | 10 |
| short | 2 bytes | 200 |
| int | 4 bytes | 5000 |
| long | 8 bytes | 100000L |
| float | 4 bytes | 10.5f |
| double | 8 bytes | 99.99 |
| char | 2 bytes | ‘A’ |
| boolean | 1 bit | true |
class DataTypesExample {
public static void main(String[] args) {
int age = 22;
double salary = 45000.50;
char grade = 'A';
boolean status = true;
System.out.println(age);
System.out.println(salary);
System.out.println(grade);
System.out.println(status);
}
}
Non-primitive data types are used to store complex data and objects.
Examples:
Example:
String name = "Java Programming";
Variables in Java are containers used to store data values.
A variable contains:
dataType variableName = value;
Example:
int marks = 95;
Correct Examples:
int studentAge;
double totalMarks;
Incorrect Examples:
int 1age;
double total marks;
Variables declared inside methods.
Example:
void display() {
int number = 10;
}
Variables declared inside class but outside methods.
Variables declared using static keyword.
Operators in Java are symbols used to perform operations on variables and values.
Java operators are important for:
Used for mathematical calculations.
| Operator | Meaning |
|---|---|
| + | Addition |
| – | Subtraction |
| * | Multiplication |
| / | Division |
| % | Modulus |
class ArithmeticExample {
public static void main(String[] args) {
int a = 10;
int b = 5;
System.out.println(a + b);
System.out.println(a - b);
System.out.println(a * b);
System.out.println(a / b);
}
}
Used for comparison.
| Operator | Meaning |
|---|---|
| == | Equal to |
| != | Not equal to |
| > | Greater than |
| < | Less than |
| >= | Greater than equal to |
| <= | Less than equal to |
int x = 20;
int y = 10;
System.out.println(x > y);
Used for combining conditions.
| Operator | Meaning |
|---|---|
| && | Logical AND |
| || | Logical OR |
| ! | Logical NOT |
boolean a = true;
boolean b = false;
System.out.println(a && b);
Used to assign values.
| Operator | Meaning |
|---|---|
| = | Assign |
| += | Add and assign |
| -= | Subtract and assign |
Example:
int number = 10;
number += 5;
Used with single operand.
Example:
int x = 5;
x++;
Understanding data types and variables helps students:
Operators are used in:
Incorrect:
int salary = 50000.75;
Correct:
double salary = 50000.75;
Using variables without assigning values can create errors.
Beginners often confuse:
These concepts help students:
In this lesson, students learned:
These concepts form the foundation of Java programming and software development.
Data types define the type of data a variable can store.
A variable is a container used to store data values.
Primitive data types include int, double, char, boolean, float, and others.
Operators are symbols used to perform calculations and comparisons.
= is used for assignment, while == is used for comparison.
Data types help optimize memory usage and ensure correct data storage.
WhatsApp us