Advertisement
JeffGrigg

ScannerSpaceJoin

Apr 17th, 2025
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.58 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.  
  7.         System.out.println("Enter the strings to join");
  8.         String s1 = sc.nextLine();
  9.         String s2 = sc.nextLine();
  10.         String s3 = sc.nextLine();
  11.  
  12.         System.out.println("Enter delimiter[like -/./ ]: ");
  13.         String delimiter = sc.nextLine();
  14.         System.out.println("delimiter is >" + delimiter + "<");
  15.  
  16.         String result = String.join(delimiter, s1, s2, s3);
  17.         System.out.println(result);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement