Print Multiple Data Types Together

This program prints integer, double, and string variables together.

Problem Statement

Write a Java program that declares variables of different types and prints them together.

Source Code

1 public class MultipleTypes {
2 public static void main(String[] args) {
3 int id = 101;
4 double salary = 55000.75;
5 String name = "Eduinq Employee";
6 System.out.println("ID: " + id + ", Name: " + name + ", Salary: " + salary);
7 }
8 }

Program Output

ID: 101, Name: Eduinq Employee, Salary: 55000.75

Explanation

An integer, a double, and a string variable are declared and concatenated together in a single println statement, showing how multiple data types can be printed together.

Quick Links to Explore