write a program in java in which there is a clss readline. the functionality of this class is to read a string from the console and display it on the console .A point that should be keep in mind is that ,your program must get and after displaying the string of inputted . you can use some symbol/character as a terminator///
Ads
Hi Friend,
Try the following code:
import java.util.*; class ReadLine{ public static String read() { String st = ""; Scanner input=new Scanner(System.in); st = input.nextLine(); return st; } public static void main(String[] args){ System.out.print("Enter Name: "); String name=read(); System.out.println("Hello "+name+"!"); } }
Thanks
Ads