Software & Finance





Java - Reading and Displaying Strings





 

Here is the Java Source Code on how to read a string and display the string on screen.

 

 

Source Code


import java.io.*;

 

 

class ReadAndDisplayString { 

 

    public static void main(String[] args) {

 

            String inpstring = "";

            InputStreamReader input = new InputStreamReader(System.in);

            BufferedReader reader = new BufferedReader(input);

 

            try

            {

                  System.out.print ("Enter a String:");

                  inpstring = reader.readLine();

                  System.out.println(inpstring.toString());

            }

            catch (Exception e)

            {

                  e.printStackTrace();

            }

    }

}

 

 

Output


C:\Java\Samples>javac ReadAndDisplayString.java

 

C:\Java\Samples>java ReadAndDisplayString

Enter a String: softwareandfinance.com

softwareandfinance.com