[Java] Appropriate introduction by the people of Tempa Java Part 0 (Code rules)

Code rules

The 0 is an extra edition, or something that you will understand somehow, but it is very important. The main story is from Part 1. I also write a description of the series. https://qiita.com/Shodai-Kurasaki/items/99cf6b0ec1a8e80640b1

{ } about

Sample1.java


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

As you can see, there is a {} in the code. If you move a lot of code, you will find out where it is, but what you should remember is ** Make sure the number of {and} is the same ** That is (exception: {does not count as a character). I think I'll soon write a program that uses this set a lot, but if I don't have enough at that time, it won't work anymore. ** To prevent it, each set of {} is stepped. It is normal to press the tab key once. ** **

; about

System.out.println ("Hello World!") **; ** โ† This ** Basically, always add it to the end of one sentence. ** Exceptions are followed by {}.

class Sample1
{โ† like this{}Except for the one that comes behind;I will put on.

It won't work without it. By the way, it doesn't mean that it doesn't work unless you put a line break after this.

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

There is no problem. However, basically it will be difficult to see, so please start a new line.

File name and class name

Sample1.java


class Sample1 โ† This is the class name
{
		public static void main(String[] args)
		{
			System.out.println("Hello World!");
		}
}

** The class name should be the same as the file name **. It can be different, but don't think about it at first. By the way, the extension of the file should be saved as .java.

Comment text

In the program, there will be places where you want to keep notes. For example, "This sentence is for displaying Hello World!". In such a case, write ** // ** and write a memo after that. // After that, it will be completely ignored when the program is executed, so you can write it as you like. However, // only notes the contents after // on that line. If you want to make a note over multiple lines, use ** / * * / ** to insert the note.

Sample1.java


class Sample1
{
		public static void main(String[] args)
		{
			System.out.println("Hello World!"); //Here is a memo

            /*Here also~~~~~~~~~~~~~~~~~~~~~~~~~~~
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Note*/
		}
}

end

If you have any points to be corrected, please point them out.

Recommended Posts

[Java] Appropriate introduction by the people of Tempa Java Part 0 (Code rules)
Output of the book "Introduction to Java"
[Java] The confusing part of String and StringBuilder
[Java] Basic summary of Java not covered by Progate ~ Part 1 ~
A review of the code used by rails beginners
Introduction of Docker --Part 1--
Quick learning Java "Introduction?" Part 2 Let's write the process
[Introduction to Java] List of things that got caught by the 14th day of programming
The part I was addicted to in "Introduction to Ajax in Java Web Applications" of NetBeans
Replace only part of the URL host with java
Understand the Singleton pattern by comparing Java and JavaScript code
[Java] Basic summary of Java not covered by Progate ~ Part 2 ยท List ~
Traps brought about by the default implementation of the Java 8 interface
Summary of values returned by the Spliterator characteristics method #java
Understand the Iterator pattern by comparing Java and JavaScript code
Switch the version of java installed by SDKMAN when moving directories
The story of not knowing the behavior of String by passing Java by reference
Part 4: Customize the behavior of OAuth 2.0 Login supported by Spring Security 5
Qualify only part of the text
[Rails] Introduction of Rubocop by beginners
[Java version] The story of serialization
[Java] Output by FormatStyle of DateTimeFormatter
Basic usage of java Optional Part 1
Arbitrary string creation code by Java
Think about the 7 rules of Optional
Server processing with Java (Introduction part.1)
The origin of Java lambda expressions
Summary about the introduction of Device
Basic structure of Java source code
Code of the part where server.servlet.session.timeout is set in spring.session.timeout in spring-boot2 system
Check the domain by checking the MX record of the email address with java
<Java> Quiz to batch convert file names separated by a specific character string with a part of the file name