0% found this document useful (0 votes)
4 views2 pages

Java Topics With Examples

The document outlines important Java programming topics, including class structure, data types, control flow with if-else statements, loops, and input handling using the Scanner class. It provides code examples for each topic to illustrate their usage. The examples demonstrate basic concepts such as printing output and taking user input.

Uploaded by

ajaykumarjagat07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Java Topics With Examples

The document outlines important Java programming topics, including class structure, data types, control flow with if-else statements, loops, and input handling using the Scanner class. It provides code examples for each topic to illustrate their usage. The examples demonstrate basic concepts such as printing output and taking user input.

Uploaded by

ajaykumarjagat07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Java Important Topics with Examples

1. Class and main method


public class Hello {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}

2. Data types and variables


int age = 25;
double salary = 50000.50;
char grade = 'A';
String name = "Ajay";
boolean isPass = true;

3. If-else statements
int number = 10;
if(number % 2 == 0) {
System.out.println("Even number");
} else {
System.out.println("Odd number");
}

4. Loops (for, while)


// For loop
for(int i = 1; i <= 5; i++) {
System.out.println(i);
}

// While loop
int j = 1;
while(j <= 5) {
System.out.println(j);
j++;
}

5. Taking input using Scanner


import java.util.Scanner;

Scanner sc = new Scanner(System.in);


System.out.print("Enter your name: ");
String name = sc.nextLine();
System.out.println("Hello " + name);

6. Printing output using System.out.println()


System.out.println("Welcome to Java Programming!");

You might also like