RUVIDEO
Поделитесь видео 🙏

Java Language Tutorial 2 First Program System out println and difference between print and println

📁 Обучение 👁️ 15 📅 05.12.2023

This tutorial is made for learning about the First Java Program of Java Programming Language.

Creating a Java program. A program is nothing more than a sequence of characters, like a sentence, a paragraph, or a poem. To create one, we need only define that sequence characters using a text editor in the same way as we do for e-mail. HelloWorld.java is an example program. Type these character into your text editor and save it into a file named HelloWorld.java.

Compiling a Java program. At first, it might seem to you as though the Java programming language is designed to be best understood by the computer. Actually, to the contrary, the language is designed to be best understood by the programmer (that's you). A compiler is an application that translates programs from the Java language to a language more suitable for executing on the computer. It takes a text file with the .java extension as input (your program) and produces a file with a .class extension (the computer-language version). To compile HelloWorld.java type the boldfaced text below at the terminal. (We use the % symbol to denote the command prompt, but it may appear different depending on your system.)

Executing a Java program. Once you compile your program, you can run it. This is the exciting part, where the computer follows your instructions. To run the HelloWorld program, type the following at the terminal:
java HelloWorld

Creating a Java program. A program is nothing more than a sequence of characters, like a sentence, a paragraph, or a poem. To create one, we need only define that sequence characters using a text editor in the same way as we do for e-mail. HelloWorld.java is an example program. Type these character into your text editor and save it into a file named HelloWorld.java.

Start NetBeans IDE.
In the IDE, choose File New Project, as shown in the figure below.
NetBeans IDE with the File New Project menu item selected.
In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Then click Next.
New Project wizard: Choose Project
In the Name and Location page of the wizard, do the following (as shown in the figure below):
In the Project Name field, type HelloWorldApp.
Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.
In the Create Main Class field, type helloworldapp.HelloWorldApp.
New Project wizard: Name and Location
Click Finish.
The project is created and opened in the IDE. You should see the following components:
The Projects window, which contains a tree view of the components of the project, including source files, libraries that your code depends on, and so on.
The Source Editor window with a file called HelloWorldApp open.
The Navigator window, which you can use to quickly navigate between elements within the selected class.

System.out.print

• System is a class.
• It contains a static object out.
• out is an object of class PrintStream.
• PrintStream class contains static function print and println.

Println - adds a new line to the end of the line. Puts the cursor on a new line

Print - prints out the line and the cursor is placed directly after it

Difference between print() and println()

The only difference between the print() and println() methods is that the println() statement positions the cursor onto the next line after printing the desired text while the print() method leaves the cursor on the same line. The difference is evident when we print text using more than a single statement. The following statements use the print() method.

System.out.print("Hello ");
System.out.print("World ");

The output of these statements would be:

Hello World

After printing the word 'Hello', the cursor remained on the same line. That is why 'World' was also displayed on the same line. If we use the println() statement, the output would be different.

System.out.println("Hello ");
System.out.println("World ");

The output would be

Hello
World

After printing the word 'Hello', the cursor moved to the next line. That is why the word 'World' was printed on a new line.

Concatenation using + operator

We can use the concatenation operator + to join two or more Strings and print them. To print the value of a variable, we simply state it within the parentheses. Look at the following code for example:

int a=1;
String s = "World";
System.out.println(a+" "+"Hello "+s+"!");

The output would be

1 Hello World!

The expression within the parentheses is evaluated from left to right and particular care has to be taken when including variables that store integers, real numbers and characters.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java Language Tutorial 2 First Program System out println and difference between print and println», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.