ATENCIÓN AL CLIENTE: +34 923 199 148

Lectura de un texto por teclado y presentación por pantalla

Lectura por teclado de un texto que se almacena en una variable tipo String y luego se presenta por pantalla.

import java.io.*;

public class interfaz_teclado_pantalla
{
   public static void main(String [] args)
   {
      //leer por teclado un string
      try
      {
         InputStreamReader leer = new InputStreamReader(System.in);
         BufferedReader buff = new BufferedReader(leer);
         System.out.print("Escriba el texto: ");
         String texto = buff.readLine();
         //salida por pantalla del texto introducido
         System.out.println(texto);
      }
      //leer del teclado como String
      catch(java.io.IOException ioex) {}
   }
}

Quizá te interese...