KEMBAR78
I Have Handwritten and Scanned Java Class Notes in | PDF | Image Scanner | Computer Programming
0% found this document useful (0 votes)
81 views7 pages

I Have Handwritten and Scanned Java Class Notes in

Uploaded by

22273cm039
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)
81 views7 pages

I Have Handwritten and Scanned Java Class Notes in

Uploaded by

22273cm039
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/ 7

I have handwritten and scanned Java class notes

in the attached and i want them converted into a


clean, well-formatted digital version so i can easily
read them on my mobile.
Got it ✅ Thanks for sharing your scanned handwritten Java class notes. I’ll help you convert
them into a clean, well-formatted digital version that you can easily read on your mobile.
Here’s the organized and formatted digital version of your “Java-2” notes:

📘 Java Notes (Clean Digital Version)


1. Reading Data using Scanner Class
Scanner is a class in the java.util package.
Import statements:
import java.util.*;
// OR
import java.util.Scanner;

Creating an object:
Scanner s = new Scanner(System.in);

Common Scanner methods:


nextInt() → Reads integer
nextFloat() → Reads float
nextDouble() → Reads double
next() → Reads string (no spaces)
nextLine() → Reads a full line of text
2. Arithmetic Operators
+→ Addition / String concatenation
-→ Subtraction
*→ Multiplication
/→ Division
%→ Remainder (modulus)
📌 Example:

int a = 10, b = 5;
System.out.println(a + b); // 15
System.out.println(a - b); // 5
System.out.println(a * b); // 50
System.out.println(a / b); // 2
System.out.println(a % b); // 0

3. Example Programs

Program: Sum of Two Numbers

import java.util.*;
class FindSum {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter first number: ");
int a = s.nextInt();
System.out.print("Enter second number: ");
int b = s.nextInt();
int sum = a + b;
System.out.println("Sum = " + sum);
}
}

Program: Area of Circle

import java.util.*;
class FindArea {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter radius: ");
float radius = s.nextFloat();
float area = 3.14f * radius * radius;
System.out.println("Area of Circle = " + area);
}
}
Program: Print Name Twice

import java.util.*;
class PrintName {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter Name: ");
String name = s.nextLine();
System.out.println(name + " ... " + name);
}
}

Program: (a+b)²

import java.util.*;
class SquareApp {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter a: ");
int a = s.nextInt();
System.out.print("Enter b: ");
int b = s.nextInt();
int result = (a*a) + (b*b) + (2*a*b);
System.out.println("(a+b)^2 = " + result);
}
}

4. Escape Characters
\n → Newline
\t → Tab
\" → Double quote
\' → Single quote
\\ → Backslash
Example:

class EscapeDemo {
public static void main(String[] args) {
System.out.println("Hello\nWorld");
System.out.println("Java\tProgramming");
System.out.println("\"Quotes\"");
System.out.println("\\Backslash\\");
}
}
5. Relational Operators
== Equal to

!= Not equal to
> Greater than
< Less than

>= Greater than or equal to


<= Less than or equal to
📌 Returns boolean values (true / false).

6. Logical Operators
&& → Logical AND
|| → Logical OR
!→ Logical NOT
Example:

System.out.println(10 > 7 && 8 == 7); // false


System.out.println(10 > 7 || 8 == 7); // true
System.out.println(!(10 == 10)); // false

7. Assignment Operators
= Assignment

+=, -=, *=, /=, %= Shorthand assignment


Example:

int a = 5;
a += 3; // a = 8
a *= 2; // a = 16

8. Increment and Decrement Operators


Pre-increment (++x) → increases value immediately
Post-increment (x++) → increases value after use
Pre-decrement (--x)
Post-decrement (x--)
Example:
int a = 5;
System.out.println(++a); // 6
System.out.println(a++); // 6 → then becomes 7
System.out.println(a); // 7

9. Bitwise Operators
~ Complement

<< Left shift


>> Right shift
& Bitwise AND
| Bitwise OR
^ Bitwise XOR

10. Conditional Operator (Ternary ?:)

int n = 10;
String msg = (n % 2 == 0) ? "even" : "odd";
System.out.println(msg);

11. Control Structures

If Statement

if (condition) {
// code
}

If-Else

if (n > 0)
System.out.println("Positive");
else
System.out.println("Negative");

Nested If

if (test1 > 50) {


if (test2 > 70)
System.out.println("Qualified");
else
System.out.println("Not Qualified");
}

If-Else If

if (n == 0)
System.out.println("Zero");
else if (n > 0)
System.out.println("Positive");
else
System.out.println("Negative");

12. Switch Statement


Syntax:

switch (expression) {
case value1: // code; break;
case value2: // code; break;
default: // code;
}

Example: Integer Switch

int n = 2;
switch (n) {
case 1: System.out.println("Cat"); break;
case 2: System.out.println("Dog"); break;
default: System.out.println("Others");
}

Example: Character Switch

switch ('+') {
case '+': System.out.println("Sum"); break;
case '*': System.out.println("Product"); break;
default : System.out.println("Not available");
}

Example: String Switch

String state = "ap";


switch (state) {
case "ap": System.out.println("Amaravati"); break;
case "tn": System.out.println("Chennai"); break;
case "mh": System.out.println("Mumbai"); break;
default : System.out.println("Not available");
}

✅ I’ve structured your notes into easy-to-read sections with examples. This is now mobile-
friendly, clean, and much easier to revise.
Would you like me to also make a downloadable PDF/Word file of these formatted notes so you
can keep them offline on your phone?

You might also like