Declare more than one variable in a single statement - Java Language Basics

Java examples for Language Basics:Variable

Introduction

For example, the following code declares variables named x and y, and initializes x to 5 and y to 10:

Demo Code

public class Main {
  public static void main(String[] args) {
    int x = 5, y = 10;
    /*from ww  w .  j  a va 2 s .c om*/
    System.out.println(x);
    System.out.println(y);
  }
}

Related Tutorials