taking string input in java

Java
Scanner in = new Scanner(System.in);
String s = in.nextLine();import java.util.Scanner;
Source

Also in Java: