Studying Java-Part 1-Hello World

1.First of all

I will write a program from this time! Yeah Even so, first of all, there is an environment where the program can be run, and we have to test whether it works.

First, download the JDK, install it, and set environment variables. Also, it will be easier in the future if you install the IDE. (IDE is software that supports programming)

I will omit the procedure. sorry. ~~ I want to mainly describe the explanation of Java itself ~~ Try searching below. JDK: java jdk installation IDE: ʻeclipse installation` (I often use Eclipse, so I will explain it to the Eclipse standard)

My environment is as follows, so I will write articles based on this environment in the future. Java version "1.8.0_111" Eclipse Neon 4.6.1

2. Create source file

Once you have an Eclipse environment, let's create a project and create a file called Main.java! Creating a Java project → Eclipse ~ Creating a Java project ~

We will proceed on the premise that the project structure is completed as follows. キャプチャ_4.PNG

First, let's create a [Main.java] file!

Right click on "src" → "New" → "Other" キャプチャ_10.PNG

Select "Class" → click "Next" キャプチャ_11.PNG

Enter "Main" in the name → click "Done" (You can choose the name you like, but for progressive reasons, enter Main. Will you know why later?) キャプチャ_12.PNG (The package is blank. It says "We do not recommend using the default package.", But ignore it for now.)

If you can create it, it will look like the one below. キャプチャ_13.PNG

This completes the file creation.

  1. Hello World Now that we have the files, let's program!

First, to open the file and make it writable Double-click "Main.java" in the red frame キャプチャ_14.PNG

This will open the file. キャプチャ_15.PNG

Enter the following program in the opened file. (Manual input is recommended, not copy)

Main.java


public class Main {
	public static void main(String[] args) {
		System.out.println("Hello World");
	}
}

Save it when you're done (you can easily save it with [Ctrl + S])

Once saved, the program is running! Right-click "Main.java"-> "Run"-> "2 Java Application" キャプチャ_16.PNG

When you run it, you'll see something called a "console". キャプチャ_17.PNG

And did the console display "Hello World"? If it appears, the program is perfect! (If you get an error, maybe something is wrong with the program?)

4. Start of processing

In Java applications, processing starts with public static void main (String [] args) {...}. (Called the main method)

Write the process in {} and add a; (semicolon) at the end for each process. Is ";" a "kuten (.)" In Japan and a "period (.)" In the United States?

And basically, the processing is done from top to bottom.

This time, I wrote a one-line process of "System.out.println (" Hello World ");". This is a command to output the string "Hello World" to the standard output (this time the console). It might be a good idea to change "Hello World" to "hoge hoge".

Other details will be understood later, so for now, please leave it on the edge of your head lol

5. Conclusion

This is the beginning for the time being. You have taken a step forward as a programmer.

I think that beginners will often stumble when they say, "The program does not improve" or "I don't know how to improve".

The way to improve your program is to write it as you like. In future articles, I will post some sample programs with explanations, but please rewrite those programs. Please do a lot of things such as "What if I rewrite this part like this?" And "It seems to be more interesting if I add such a function here."

(By the way, I think that my improvement was when I finished studying Java and made the first program to create a QR code from a string of numbers.)

It's also good to have goals at all times to improve. If there is something you want to make, you may find out about it, or you may devise your own. I recommend that you use the knowledge and experience gained in this way because you will surely find it useful somewhere in the program.

Next time, essential knowledge for programming! variable! I would like to talk about

Next time → "Study Java-Part 2-Variables"

Recommended Posts

Studying Java-Part 1-Hello World
Studying Java-Part 0-Overview
Studying Java-Part 4-Literal
Studying Java-Part 5-Constant
Read "Hello world"
Java, Hello, world!
Studying Java-Part 2-Variables
Java Hello World
Studying Java-Part 9-Scope
Studying Java-Part 7-Array
Studying Java-Part 3-Type
"Hello World" in Java
Java Learning (1)-Hello World
Read System.out.println ("hello, world")
Let's write Hello World
Hello World in Java
Studying Java-Part 10-if statement
Hello World on WebAssembly
Hello World with Micronaut
Studying Java-Part 11-switch statement
Hello World with Spring Boot
Hello World with Spring Boot!
Hello World with VS Code!
java hello world, compile, run
Hello World with Spring Boot
Java beginners read Hello World
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
Spring Boot Hello World in Eclipse
Hello World for ImageJ Java Plugin
Until "Hello World" with Spring Boot
Hello world with Kotlin and JavaFX
Hello World with Docker and C
(Intellij) Hello World with Spring Boot
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
hello, world in Vanilla Java-EHW2018 "MVP"
"Hello world" for ImageJ with Eclipse
Hello World with GWT 2.8.2 and Maven
Android OS (7.1.2) build and Hello World
Hello world in Java and Gradle
Creating an Elasticsearch Plugin Series (1) Hello World
Hello World with Eclipse + Spring Boot + Maven
Hello, World! In the bootstrap loader area
Hello world with Java template engine Thymeleaf
Java development with Codenvy: Hello World! Run
"Hello, World!" With Kotlin + CLI in 5 minutes
Hello World on Mac VS Code Java
Introduction to Ratpack (3) --hello world detailed explanation
Hello world with Kotlin and Tornado FX
How Spring Security works with Hello World
(IntelliJ + gradle) Hello World with Spring Boot
Minimal Java environment construction and Hello World