bufferead Java program to read integer data from the user code example

Example 1: how to read integer input using bufferedreader java

BufferedReader reader =new BufferedReader(new InputStreamReader(System.in));
int num = Integer.parseInt(reader.readLine());

Example 2: BufferredReader Class

package com.javatpoint;  
import java.io.*;  
public class BufferedReaderExample{    
public static void main(String args[])throws Exception{             
    InputStreamReader r=new InputStreamReader(System.in);    
    BufferedReader br=new BufferedReader(r);            
    System.out.println("Enter your name");    
    String name=br.readLine();    
    System.out.println("Welcome "+name);    
}    
}

Tags:

Java Example