Input and output in java

By: aathishankaran Printer Friendly Format    

Input and output in java


In the examples the keyword display was used for displaying the results of programs. The keyword display can be used for displaying constants as well as variables.




  • display Salary;

This displays the value stored in the numeric variable Salary on the screen


  • display “Manila”;

This displays the string “Manila” on the screen


The keywords accept is used to obtain values from the user through the input device (Keyboard).




accept Salary;


This causes the program to wait for the user to type numeric value. The numeric value entered by the user will be stored in the variable Salary.


The following program accepts a name from the user and displays the same.




            char Name;

            display “Enter Name:”;

            accept Name;

            display “Hello”;

            display Name;



If the name is typed as “Robinson”, it will display:


Hello Robinson


On the screen

Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial