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
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.
First, let's create a [Main.java] file!
Right click on "src" → "New" → "Other"
Select "Class" → click "Next"
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?) (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.
This completes the file creation.
First, to open the file and make it writable Double-click "Main.java" in the red frame
This will open the file.
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"
When you run it, you'll see something called a "console".
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?)
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
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