Language syntax

Local variable declaration

Introduces a local variable and optionally initializes it. The variable must be definitely assigned before reading.

Formal Syntax & Structure

java syntaxjava
Type name = expression;

Working Example

Example Snippetjava
public class Main {    public static void main(String[] args) {        int seats = 20;        System.out.println(seats);    }}
Java Reference