Java Presentation - Objective 3
Input in Java
Definition:
Input means getting data from the user.
How:
Use the Scanner class from [Link] to read user input.
Example:
import [Link];
Scanner scan = new Scanner([Link]);
[Link]("Enter your name: ");
String name = [Link]();
[Link]("Hello " + name);
Meaning of Scanner:
Scanner reads data typed by the user (like numbers or words).
Output in Java
Definition:
Output means displaying information to the user.
Ways to Output:
1. [Link]() – prints text with a new line
Example:
[Link]("Hello!");
2. [Link]() – prints text without a new line
Example:
[Link]("Hello ");
3. [Link]() – prints formatted text
Example:
[Link]("Age: %d", 18);
Data Types in Java
Definition:
Data types tell Java what kind of value a variable holds.
Primitive Types:
int – whole numbers
double – decimals
char – single character
boolean – true/false
Reference Type:
String – group of characters (text)
Operators in Java
Definition:
Operators perform actions on values or variables.
Types (with examples):
Arithmetic: +, -, *, /, % → int sum = 5 + 3;
Comparison: ==, !=, >, < → x > y
Logical:
&& (AND) → true if both are true
|| (OR) → true if one is true
! (NOT) → reverses value
Example:
if (x > 5 && y < 10) {
[Link]("Both conditions true");
}