How to Combine Text and a Variable in Java


In this example, we will learn the method to combine text and a variable in Java.

Source Code

package com.beginner.examples;

public class CombineText {
  public static void main(String[] args) {
    String str = "Hello ";
    System.out.println(str + "World"); // combine text and a variable
  }
}

Output:

Hello World
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments