유튜브 설명칸

Hello world program source code:

class Main {

public static void main(String[] args) {

System.out.println(”Hello world”);

}

}

Lesson Script

Introduction

In this tutorial we will be learning about Java output. We will take a look at this line, System.out.println. This is what typically use to print something to a standard output.

In this lesson, you have to understand what exactly a standard output is.

Standard output

First, I will explain what a standard output is. So you have a computer and you have a operating system. You run a program in that operating system. When you run a program, the operating system allocates a console for the program. This is the standard output. It is a fair name because when a program starts, a console is created just for that program! If you run multiple programs, the operating system will allocate a console for each program you run. So each program has its own standard output. So to re-emphasize, this console that we have been seeing since the very start of the lesson, this is a special thing called the standard output. But there are many outputs that are not the standard output. Your program could output some text to a file, or to another program. So by output we mean, the program sends some text to something other than itself. This can be any sort of things. And the console is the most basic, place to output something, hence the name standard output.

System.out

So System.out is what we use to output to the console, or, the standard output. In order to fully understand what the System.out is, you have to continue taking this tutorial course, and I will explain more advanced stuff like PrintStream, Input / Output buffer, later on in this course. For now. you just have to know that we will use the methods print() and println() to print stuff to the standard output.

Additional Learning Material

PrintStream

Second, you have to know what a PrintStream object is. So you use a PrintStream object to

PrintStream ps = new PrintStream("output.txt"); ps.println("This goes to a file."); ps.close();

PrintStream methods

Standard output in C and Java