- Version
- Download 16
- File Size 2.46 KB
- File Count 1
- Create Date April 18, 2016
- Last Updated April 18, 2016
String Concatenation in Java
String Concatenation in Java
Concatenation is joining or combining two or more strings. In this java program, we are going to combine two strings to form a single one. This program will accept inputs from the user using the scanner class. It’s available in console and gui version.
Source code:
import javax.swing.*;
class ConcatStringGUI
{
public static void main(String[] args) {
String firstname ;
String lastname ;
firstname = JOptionPane.showInputDialog(null,"Enter your firstname:");
lastname = JOptionPane.showInputDialog(null,"Enter your lastname:");
JOptionPane.showMessageDialog(null,"Your fullname:" + firstname + lastname);
}
}