[Go to site: main page, start]

0% found this document useful (0 votes)
6 views4 pages

Java Basics: Hello World & Loops

The document provides examples of basic Java programming concepts including printing 'Hello World', arithmetic operators, if-else statements, and loops (for, while, and do-while). Each section includes code snippets and their corresponding outputs. It serves as a brief introduction to fundamental Java syntax and operations.

Uploaded by

padmalhadon6
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)
6 views4 pages

Java Basics: Hello World & Loops

The document provides examples of basic Java programming concepts including printing 'Hello World', arithmetic operators, if-else statements, and loops (for, while, and do-while). Each section includes code snippets and their corresponding outputs. It serves as a brief introduction to fundamental Java syntax and operations.

Uploaded by

padmalhadon6
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 Programming

[Link] Hello World in java?


public class HelloWorld {
public static void main(String[] args)
{
[Link](“Hello World”);
}
}
Output:Hello World
[Link] Of arithmetic operators in java?
public class Operators {
public static void main(String[] args)
{
Int a=10;
Int b=5;
[Link](a+b);
[Link](a-b);
[Link](a*b);
[Link](a/b);
}
}
Output:
15
5
50
2
3.if_else statement in java?
public class IfElse
{
public static void main(String[] args)
{

int n = 10;

if (n %2==0)
{
[Link]("The number is even.");
}
else
{
[Link]("The number is odd.");
}
}
}

Output
The number is even

Q:loops in java
[Link] loop
[Link] loop
3.do_while loop

Q:program of for loop in java?


Class forloop
{
public static void main(String[] args)
{
int i;
for (i = 0; i <= 10; i++)
{
[Link](i);
}
}
}
Output: 0,1,2,3,4,5,6,7,8,9,10

Q:program of while loop in java?


class whileloop
{
public static void main(String[] args)
{
int i = 0;
while (i <= 10)

{
[Link](i);
i++;
}
}
}
Output: 0,1,2,3,4,5,6,7,8,9,10
Q:program of do_while loop in java?
class do_while
{
public static void main(String[] args)
{
int i = 0;
do
{
[Link](i);
i++;
}
while (i <= 10);
}
}
Output: 0,1,2,3,4,5,6,7,8,9,10

You might also like