Symphonice Blog

welcome

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

Menggunakan Buffered Reader untuk mendapatkan input


Pada bagian ini, kita akan menggunakan class BufferedReader yang berada di package
java.io untuk mendapatkan input dari keyboard.

langsung aja yaah

/*
 * To change this template, choose Tools | Templates and open the template in
 * the editor.
 */
package inputdarikeyboard;

/**
 *
 * @author Compaq
 */
import java.io.BufferedReader;          // import class library
import java.io.IOException;
import java.io.InputStreamReader;


public class Buffered {
 
    public static void main(String[] args) throws IOException {
       
        String nama;                                      //deklarasi variabel nama
        System.out.println("Siapa Nama Anda ?");
       
        InputStreamReader isr = new InputStreamReader(System.in);        //instansiasi input
        BufferedReader br = new BufferedReader(isr);                    //instansiasi br dan memanggil isr
       
        nama = br.readLine();                             //untuk membaca variabel nama
        System.out.println("Halo " +nama+ " apa kabarnya ?");
       
        String hobi;
        System.out.println("Apa hobi anda ?");
        InputStreamReader hby = new InputStreamReader(System.in);   //instansiasi input
        BufferedReader hbi = new BufferedReader(hby);                  //instansiasi br dan memanggil isr
       
        hobi = hbi.readLine();
        System.out.println("Oh hobi anda " +hobi);
        }
}

dan hasil nya seperti ini


selamat mencoba semoga berhasil :)

0 komentar:

Posting Komentar

My Blog List

Post-it Widget

Another Source

Pages

About Me

Followers