In C language, the input and output are printf(); and scanf(); In C++ language, it is cout <<;; and cin >>.
Java has System.out.println(); System.out.print(); and so on I wonder if there is a command to enter. When you're reading books and doing things like typing, At startup, add the args[] array to the
int variable = args[0]; I did it like this
Is there a command that you can input directly from the console like scanf?
java
You can use System.in. Refer to the following code for more information. If you want to learn more, I recommend you to listen to the next lecture.
http://tryhelloworld.co.kr/courses/ Java-introduction/lessons/char-unit-input/output console
import java.io.BufferedReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class CharIOExam01 {
public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//declare a line variable to store the string entered by the keyboard
String line = null;
try {
line = br.readLine()
} } catch (IOException e) {
e.printStackTrace();
}
//Out to Console
System.out.println(line);
}
}
© 2024 OneMinuteCode. All rights reserved.