Skip to main content
Documents
Share
LinkedIn
Facebook
Twitter
Copy
Java keywordsIntroduction To JavaJava File HandlingJava Language BasicsJava ArraysJava Object-Oriented Programming

Java Language Basics

Java is a simple, object-oriented programming language known for its readability and platform independence. Here’s a basic overview of Java syntax and some essential concepts to help you get started.

Java Output

Java uses the System.out.println() method to print text to the console. It is commonly used for displaying output.

Java Comments

Comments in Java are used to explain code and are ignored by the compiler. There are three types: single-line, multi-line, and Javadoc comments.

Java Variables

Variables are used to store data. In Java, variables must be declared with a data type before use.

Java Data Types

Java has two categories of data types: primitive types (such as int, double, char, boolean) and reference types (such as objects and arrays).

Java Type Casting

Type casting is the process of converting a variable from one data type to another. There are two types: widening casting (automatic) and narrowing casting (manual).

Java Operators

Operators in Java perform operations on variables and values. Common types include arithmetic, comparison, and logical operators.

Java Strings

Strings represent text and are objects in Java. They are immutable, meaning their values cannot be changed after they are created.

Java Math

The Math class provides methods for performing numeric operations, such as square root, power, and rounding.

Java Booleans

A boolean represents one of two values: true or false. It is commonly used for conditional logic.

Java If...Else

The if...else statement is used for conditional logic, executing code blocks based on whether a condition is true or false.

Java Switch Statement

The switch statement tests a variable for equality against a list of values, allowing different actions based on the value.

Java While Loop

The while loop repeatedly executes a block of code as long as the given condition is true.

Java For Loop

The for loop is used for executing a block of code a specific number of times.

Java Break and Continue

The break statement is used to exit a loop prematurely, while the continue statement skips the current iteration and moves to the next one.