Print Multiple Variables
This program prints multiple variables in one statement.
Problem Statement
Write a Java program that declares multiple variables and prints them together.
Source Code
| 1 | public class PrintMultiple { |
| 2 | public static void main(String[] args) { |
| 3 | int id = 101; |
| 4 | String name = "Eduinq"; |
| 5 | System.out.println("ID: " + id + ", Name: " + name); |
| 6 | } |
| 7 | } |
Program Output
ID: 101, Name: Eduinq
Explanation
An integer id and a string name are declared and concatenated together in a single println statement, showing concatenation of multiple variables in output.