Java, Hello, world!

Introduction

This article is a memorandum. Although it is a reference book level content, the code posted in this article is about ** Wrong ** are the main things. This is for the purpose of posting the part that was actually mistaken during coding and posting it for self-reflection. In addition, I will not touch on the deep part here because I will review it later while also studying the Java Silver exam questions.

environment

Language: Java11, JDK13.0.2 Operating environment: Windows 10

What is Hello, world?

If you've ever touched programming, you've probably written it. In my vague memory, I think I wrote it in Basic or C in a computer class in junior high school (I didn't think I would jump into the world of programming at this time). By the way, I was studying to take the ** "Python3 Engineer Certification Basic Exam" ** at Python, so I wrote this from the command prompt.

Hello,world!.py


>>> python
(abridgement,python3.7.Message when starting 2)
>>>print("Hello,world!")
>>>Hello,world!  #result

I asked print and it came out immediately. After that, when I read Java, it was like this.

Hello,world!.java


//Let's make a class first
class helloWorld
{
  public static void main(String[] args)
  {
    System.out.println("Hello,world!");
  }
}

helloWorld.java


//Next, let's compile. Open the command prompt.
>>>cd C:\JavaSample
   //Move directory.
   //In other words, please specify where it is in the file.
>>>javac -encoding UTF-8 helloWorld.java
   //Now it's compilation.
   //The encoding setting doesn't work, so please specify that as well.

   //Make sure that the compiled data is in the specified folder.
>>>java helloWorld
Hello,world! 
   //It's finally completed!

...... What is this effort? !! I can't say good or bad because there are differences between Python and Java depending on the type of language (I was confused at the time, but I'm used to it).

For the time being, I wrote a few in the method and remembered it, but the problem remained. What do these in Java mean? ?? ?? I don't understand at all.

Why do you write so much?

There is almost no explanation for these strangely long descriptions in the introductory book (I regretted it after a little research based on interest). It's a little too long to say, "Let's remember this as a makurakotoba," so I wanted him to talk a little. Qiita has already dealt with this story, so I would like to introduce one (I will mention that it was an article three years ago and the latest Java is SE11).

@tomz65k9nfy Challenge to explain Java's Hello World while referring to the language specifications

Also, here is a reference issued by ʻOracle`, a company that handles Java. If you say **, I can explain if you understand this page **.

Java® Platform, Standard Edition & Java Development Kit Version 11 API Specification

I want to connect to the next

I've given you two reliance, but to be honest ** I haven't swallowed enough to explain it **. However, as a beginner, I want to write what to connect next, so I want to break down that long makurakotoba. Items to be divided by disassembly

  1. ** Qualifiers and methods **
  2. ** Each of the modifiers **

Decomposition, modifiers / methods

The target of disassembly is A sentence of public static void main (String [] args).

  1. As ** modifiers and methods ** public static void / main(String[] args)

The former has three ** modifiers **, the latter has ** methods ** and their arguments You can see that.

First of all, about the method The main () method is the java.lang.Object class, which is a ** process ** contained in the ** standard class ** prepared by Java even if nothing is declared. .. The part containing this main () becomes the ** entry point ** and the actual processing starts, and when the main () method is exited, the processing ends.

(String [] args) is an argument required by the main () method. It is divided into ** String type array ** and ʻargs argument name. It doesn't have to be named ** ʻargs ** (it doesn't matter if it's a different name, but it seems to be customary to name it). The String type is also a member of the java.lang.Object class (it has a bad word, but it is omitted here), and it can handle character strings (the char type can handle some integers and simple substances. Only one letter). In other words, it is an array of type String, and it seems that it is prepared to receive processing by giving args or another name.

Next is the modifier.

# In other words What is `public static void main (String [] args)`? Qualification: ・ Open to other classes (public) ・ (Static) associated with this class -No return value (void) Method: -Take a String type array with args name as an argument ・ Method as an entry point

...... Is it? I'm thinking now, just as the mystery has deepened.

At the end

This time I limited it to two, but what is "public static void main (String [] args)"? I saw many articles on the internet. After all it seems that there are many voices with doubts. It seems that we need to know more in order to be able to explain the question clearly. The road to the program is deep and steep.

reference

I write variables and expressions as much as possible and compile them, so if I want to quote them completely, I will describe that.

Easy Java 7th Edition Java SE11 Silver Problem Collection (commonly known as Kuromoto) Python Tutorial 3rd Edition (Note that this is the O'Reilly Japan store page)

Recommended Posts

Java, Hello, world!
Java Hello World
"Hello World" in Java
Java Learning (1)-Hello World
Java beginners read Hello World
Hello World for ImageJ Java Plugin
Hello World on AWS Lambda + Java
Read "Hello world"
Hello World in java in eclipse now
Hello Java Lambda
Hello world in Java and Gradle
Hello world with Java template engine Thymeleaf
Java development with Codenvy: Hello World! Run
Hello World on Mac VS Code Java
Minimal Java environment construction and Hello World
Read System.out.println ("hello, world")
Let's write Hello World
Hello world in node.js
Studying Java-Part 1-Hello World
Hello World on WebAssembly
Hello World with Micronaut
Build Java environment and output hello world [Beginner]
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Wastefully creative "Hello World" output method list (Java)
Hello World with Spring Boot
Java history in this world
Hello World with Spring Boot!
Hello World with VS Code!
Java
Hello World with Spring Boot
Java
Hello World with SpringBoot / Gradle
Hello, World! With Asakusa Framework!
[Java] One type of alphabet prohibited With binding Hello, world! [Binding]
Try Hello World using plain Java on a Docker container
Spring Boot Hello World in Eclipse
Until "Hello World" with Spring Boot
Hello world with Kotlin and JavaFX
Hello World with Docker and C
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
Try Hello World with the minimum configuration of Heroku Java spring-boot
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Java 10 (JDK 10) was released on March 20, 2018, so let's try Hello World.
Java learning (0)
Studying Java ―― 3
[Java] array
Java protected
[Java] Annotation
Java array
Creating an Elasticsearch Plugin Series (1) Hello World
Studying Java ―― 9
Java scratch scratch
java (constructor)
[Java] ArrayDeque