Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is the JAVA input function?
What is the JAVA input function?

In JAVA, there is no such operation as input function. Instead, input and output methods are used.

Java’s output function can directly call the print function of the out object of the System class.

System.out.print(a);//Output the value of variable a;

System.out.print("214214");//Output string;

p>

System.out.print("123"+a);//Mixed output strings and variable values;

Of course, System.out.println(); can also be used to indicate newline output , equivalent to System.out.print("\n");

Where System is a class, out is the object of java.io.PrintStream, that is, the class System contains;

The object of java.io.PrintStream is out.

Print() is a method in the java.io.PrintStream class, which is also a method of the out object.

Extended information

Java input

importjava.util.Scanner;

publicstaticvoidmain(String[]args){

Scannersc=newScanner(System.in);

System.out.println("Please enter your name:");

Stringname=sc.nextLine() ;

System.out.println("Please enter your age:");

intage=sc.nextInt();

System.out. println("Please enter your salary:");

floatsalary=sc.nextFloat();

System.out.println("Your information is as follows:");< /p>

System.out.println("Name:"+name+"\n"+"Age:"+age+"\n"+"Salary:"+salary);

}