
Write a program that reads input from the console in the form of a string. When the user enters a word called end, the program should stop reading from the console and print out the values that have been entered so far.*/

The given program reads input from the console in the form of a string. When the user enters a word called end, the program should stop reading from the console and print out the values that have been entered.
import java.io.*;
class StringExample
{
public static void main(String[] args)
{
try{
StringBuffer buffer=new StringBuffer();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter strings: ");
String st=br.readLine();
while(!st.equals("end")){
st=br.readLine();
if(!st.equals("end")){
buffer.append(st);
buffer.append("\n");
}
}
System.out.println("You have entered following strings: ");
System.out.println(buffer.toString());
}
catch(Exception e){}
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.