Menggunakan Buffreader pada Java

Kodingan :

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class KataTerakhir_BufferedReader {
  public static void main( String[] args ){
    BufferedReader dataIn = new BufferedReader(new
InputStreamReader( System.in) );
    String word1 = "";
    System.out.print("Enter Word 1 :");
    try{
      word1 = dataIn.readLine();
    }catch( IOException e ){
      System.out.println("Error!");
    }
    String word2 = "";
    System.out.print("Enter Word 2 :");
    try{
      word2 = dataIn.readLine();
    }catch( IOException e ){
      System.out.println("Error!");
    }
     String word3 = "";
    System.out.print("Enter Word 3 :");
    try{
      word3 = dataIn.readLine();
    }catch( IOException e ){
      System.out.println("Error!");
    }
    System.out.println(word1 + " " + word2 + " " + word3 );
  }
}

Output :


Tidak ada komentar:

Diberdayakan oleh Blogger.