Java Введення більше

2075 / Java / Введення / Більше

 

З спливаючими віконами для вводу

import javax.swing.JOptionPane;

String n1,n2;
int a1,a2;
n1 = JOptionPane.showInputDialog("a1 = ");
n2 = JOptionPane.showInputDialog("a2 = ");
a1 = Integer.parseInt(n1);
a2 = Integer.parseInt(n2);
JOptionPane.showMessageDialog(null, "a1=" + a1); // null - в нове вікно
JOptionPane.showMessageDialog(null, "a2=" + a2);
 

BufferedReader

import java.io.BufferedReader;

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s = br.readLine();
int i = Integer.parseInt(br.readLine());

 

DataInputStream

import java.io.DataInputStream;

DataInputStream dis = new DataInputStream(System.in);
int i = dis.readInt();

 

Console

import java.io.Console;
Console console = System.console();
String s = console.readLine();
int i = Integer.parseInt(console.readLine());