get text from a jtextfield
JTextField yourInpuFieldt = new JTextField(16);
yourInputField.setText("put your text here");
String x = yourInputField.getText();
get text from a jtextfield
JTextField yourInpuFieldt = new JTextField(16);
yourInputField.setText("put your text here");
String x = yourInputField.getText();
how to read input in java
//For continues reading a line
import java.util.Scanner;
Scanner in = new Scanner(System.in);
while(in.hasNextLine()) {
String line = in.nextLine();
System.out.println("Next line is is: " + line);
}
read input in java
3 ways to read input from console in java
-----------------------------
1. Using BufferedReader Class
2. Using Scanner Class
3. Using Console Class
//bufferedreader class
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
...
public static void main(String[] args) throws IOException
...
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String name = reader.readLine();
//Scanner class
import java.util.Scanner;
...
String name = new Scanner(System.in);
//Console class:
String name = Syste.console().readLine();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us