JAVA – Console Output Commands


Just as the Console Input command, accepts the user defined input, the Console. Output command displays the output on the monitor. In the Java programming language, you can write programs that write text lines to the console, which is a DOS based command window.

Though it’s not as popular as a Graphical User Interface or a GUI, the Console.Output command is used sometimes by programmers. Also, the Console.Output command doesn’t work properly with applets, WebStart applications and normal GUI programs. A sample code that shows the dialog or the console output program for simple input/output command is shown below:

public class example_Console_Output

{

public static void main(String[] args) {

System.out.println(“Hello, This is the example of Console Output command. “);

}

}

The System.out.println command is used to display an entire line of output on the console. The message passed as an argument to the System.out.println command is printed on the console. The println is the short form of print line command and originates from the Pascal programming language.

You can also substitute the println command with the print command. This command also prints the output to the console. However, it does not start a new line after the output is displayed.

Therefore, we can say that println is a method called by the System.out object used for displaying the console output. In this method, as you’ve already seen the data that needs to be displayed is passed as an argument to this command. The command uses a (+) sign to connenct two or more items. Not only this, each time the println command is invoked, it generates a new line once it has finished printing on the console. The example given below displays this:

System.out.println(“The answer to the question is ” + 9390);

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>