0

How to ask user to input some number and print it?

3rd Aug 2016, 11:54 AM
Hamza Merdzanic
Hamza Merdzanic - avatar
4 Réponses
+ 2
BufferedReader br = new BufferedReader(InputStreamReader(System.in)); System.out.println("Enter any no: "); int a= Integer.parseInt(br.readLine()); System.out.println(a);
3rd Aug 2016, 12:25 PM
Arghya Paul
Arghya Paul - avatar
+ 1
import java.util.*; public class Test { public static void main(String args[]){ Scanner in = new Scanner(System.in); int num=0; System.out.println("Enter a number"); try{ num = in.nextInt(); }catch(Exception ex){ System.out.println("Not allowed"); } System.out.println("num: "+num); } }
3rd Aug 2016, 1:46 PM
Ian Kahwai
Ian Kahwai - avatar
0
int a =Integer.parseint(joptionpane.showinputdialog("input no.")); system.out.print(a);
3rd Aug 2016, 3:15 PM
Sameer Ramchandani
Sameer Ramchandani - avatar
0
tnx
7th Aug 2016, 2:32 PM
Hamza Merdzanic
Hamza Merdzanic - avatar