Skip to main content

Student Portal > Contests > 

Programming Contest Central

   
Welcome students Resources Competition ProfilesFAQ
  Contest calendar
  Problem of the month
  Past problems
  Games and brainteasers
  Successes
  Tutorials

Input Output Keyboard

import java.io.*;
/**
 * The following program demonstrates how
 * you can read from the keyboard
 * and print the objects that the user has input.
 */
public class InputOutputKeyboard {
  public static void main(String[] args) throws IOException {
   
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
   

    // Reads the first line
    String line = br.readLine();
    // Prints the first line of text the user has input
    System.out.println(line);
   
    // Reads the second line
    String line2 = br.readLine();
    // Prints the second line of text the user has input
    System.out.println(line2);
   
    // Reads the third line
    String line3 = br.readLine();
    // Prints the third line of text the user has input
    System.out.println(line3);
   
  }
}


Back to top
 


Quick links

Student forum

Teacher resources

RSS Feed