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

Java Basics Learn

The document provides basic Java programming examples, including a 'Hello World' program, an addition program, and various programs that utilize the Scanner class for user input. It demonstrates how to read integers and strings from the console, and how to print formatted output. These examples serve as a foundational introduction to Java programming concepts.
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)
2 views2 pages

Java Basics Learn

The document provides basic Java programming examples, including a 'Hello World' program, an addition program, and various programs that utilize the Scanner class for user input. It demonstrates how to read integers and strings from the console, and how to print formatted output. These examples serve as a foundational introduction to Java programming concepts.
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

Java Basics – Learn PDF

1. Hello World Program


class Hello {
public static void main(String args[]) {
[Link]("Hello World");
}
}

2. Addition Program
class Equal {
public static void main(String args[]) {
int a = 20;
int b = 30;
[Link](a + b);
}
}

3. Scanner Input – Add Two Numbers


import [Link];

class Hello {
public static void main(String args[]) {
Scanner rethu = new Scanner([Link]);
int a = [Link]();
int c = [Link]();
int r = a + c;
[Link](r);
}
}
4. Name and Age Input
import [Link];

class Q1 {
public static void main(String args[]) {
Scanner rethu = new Scanner([Link]);
String name = [Link]();
int age = [Link]();
[Link]("My Name is " + name);
[Link]("My age is " + age);
}
}

5. Name, Age and Address Input


import [Link];

class Q2 {
public static void main(String args[]) {
Scanner rethu = new Scanner([Link]);
String name = [Link]();
int age = [Link]();
[Link]();
String address = [Link]();

[Link]("My Name is " + name);


[Link]("My age is " + age);
[Link]("My Address is " + address);
}
}

You might also like