Operators
Learn arithmetic, assignment, comparison and logical operators.
Java Code
Study the example and understand what each part does.
public class Main {
public static void main(String[] args) {
int a = 20;
int b = 5;
System.out.println(a + b);
System.out.println(a - b);
System.out.println(a * b);
System.out.println(a / b);
System.out.println(a % b);
}
}
Java code normally runs using the Java Development Kit on a computer, Android Studio or another Java development environment. This course page presents the code examples without pretending that the browser is running Java directly.
Expected Output / Result
25 15 100 4 0
Finished this lesson?
Mark it complete to update your course progress.