[Go to site: main page, start]

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

Java Examples

The document provides various Java programming examples, including comments, variable declarations, and different types of operators such as arithmetic, relational, logical, assignment, and casting. Each example demonstrates specific functionalities like addition, division, modulus, and increment/decrement operations. The examples serve as a basic introduction to Java syntax and operations.
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 views3 pages

Java Examples

The document provides various Java programming examples, including comments, variable declarations, and different types of operators such as arithmetic, relational, logical, assignment, and casting. Each example demonstrates specific functionalities like addition, division, modulus, and increment/decrement operations. The examples serve as a basic introduction to Java syntax and operations.
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 Examples

[Link]

// This is a single-line comment

/* This is a

multi-line comment */

[Link]

int number = 10;

String name = "Java";

boolean isActive = true;

[Link]

int a = 5;

int b = 10;

int sum = a + b;

[Link]("Sum: " + sum);

[Link]

int a = 10;

int b = 2;

int result = a / b;

[Link]("Division: " + result);

[Link]

int a = 10;
Java Programming Examples

int b = 3;

int remainder = a % b;

[Link]("Modulus: " + remainder);

[Link]

int a = 5;

int b = 10;

[Link](a < b); // true

[Link](a == b); // false

[Link]

boolean x = true;

boolean y = false;

[Link](x && y); // false

[Link](x || y); // true

[Link]

int a = 5;

a += 3; // a = a + 3

[Link](a); // 8

[Link]

int a = 5;

a++; // Increment
Java Programming Examples

[Link](a); // 6

a--; // Decrement

[Link](a); // 5

[Link]

double d = 9.7;

int i = (int) d; // Casting double to int

[Link](i); // 9

You might also like