Output of the book "Introduction to Java"

Java Primer Output Memo

Since I joined the company, I have been training + on-site learning, so "Introduction to Java: From basics with modern style to object-oriented / practical library" Buy. Output while reading. I'm still starting to read it, but I'm glad I bought it because it contains content that was pointed out in the review before and I was only thinking about "Is that so?"

Modifier

(I think it depends on the item) Pick up what you often see

□ abstract modifier: Specifies that the class, method, or IF is abstract. (For example, only the method declaration part has no contents) → The class that has the abstract method must be the abstract class. In addition, you must always create a class that inherits your own class and define the contents (abstract ='abstract' is NG).

□ static modifier: Members can be accessed even if the class is not instantiated. → You can access by class name.member (method or field) name.

□ final modifier: Prohibit overwriting of members → When specified in a field ... Prohibits overwriting the value of that field When specified in the method ... Override prohibited When specified as a class ... Subclassing is prohibited

public class Super{

	public static void print(){
		System.out.println("I am a parent class.");
	}
}

Child class

public class Sub{

	public static void print(){
		System.out.println("I am a child class.");
	}
}

If, the execution result of the print method of Sub class is "" I am a child class. It becomes "".

Overload: To define a method with the same method name but different argument types and number of arguments.


public static void print(int count){
	System.out.println(count + "I ordered 1 item.");
}

public static void print(String name, String item){
	System.out.println(name + "Is" + item + "I ordered.");
}

Naming convention

Camelcase: A notation for capitalizing word breaks. Example) getUserName

Snake case: Uppercase letters with underscores (_). Example) OUTPUT_FILE_NAME

In principle, the following rules (should be) Class name → Camel case starting with capital letters Variable name → camel case starting with lowercase letters Constant name → Snake case

Variables are nouns, methods are verbs

"IsXXX" should be avoided in the variable name of boolean. Also, although flags (flg) are often used for boolean variable names, avoid naming them with "flg" alone because it is unclear what they mean.

//Variables that manage state (named by noun)
private boolean applyFlg = false;

//Method to inquire about state (named by verb)
public boolean isApplied(){
	return this.applyFlg;
}

Recommended Posts

Output of the book "Introduction to Java"
[Java] Introduction to Java
Introduction to java
Introduction to java for the first time # 2
[Java] Color the standard output to the terminal
Introduction to java command
I want to output the day of the week
Output of how to use the slice method
[Java] How to get the authority of the folder
[Introduction to Java] Basics of java arithmetic (for beginners)
Java Welcome to the Swamp of 2D Arrays
[Java] How to get the URL of the transition source
From the introduction of devise to the creation of the users table
Convert the array of errors.full_messages to characters and output
Understand the characteristics of Scala in 5 minutes (Introduction to Scala)
[Java] How to get the maximum value of HashMap
[Java] Introduction to lambda expressions
Introduction to Java for beginners Basic knowledge of Java language ①
[Java] Introduction to Stream API
Java: Use Stream to sort the contents of the collection
[Introduction to rock-paper-scissors games] Java
Input to the Java console
[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
[Note] Java Output of the sum of odd and even elements
I tried to summarize the basics of kotlin and java
Get to the abbreviations from 5 examples of iterating Java lists
20190803_Java & k8s on Azure The story of going to the festival
[Java] To know the type information of type parameters at runtime
How to derive the last day of the month in Java
The story of pushing Java to Heroku using the BitBucket pipeline
Be sure to compare the result of Java compareTo with 0
Reintroduction to Java for Humanities 0: Understanding the Act of Programming
[Introduction to Java] Handling of character strings (String class, StringBuilder class)
[Java] Delete the elements of List
Introduction to swift practice output Chapter5
[Introduction to Java] About lambda expressions
[java8] To understand the Stream API
[Java version] The story of serialization
[Introduction to Java] About Stream API
Introduction to Functional Programming (Java, Javascript)
[Java] Input to stdin of Process
Log output to file in Java
From introduction to use of ActiveHash
Initial introduction to Mac (Java engineer)
Welcome to the Java Library Swamp! !!
From introduction to usage of byebug
The road from JavaScript to Java
The origin of Java lambda expressions
Summary about the introduction of Device
Handling of java floating point [Note] while reading the reference book
[Java] Various summaries attached to the heads of classes and members
Introduction to swift practice output Type representing the Chapter 4 collection Part 1
I tried the input / output type of Java Lambda ~ Map edition ~
Introduction to swift practice output Type representing the Chapter 4 collection Part 2
The milliseconds to set in /lib/calendars.properties of Java jre is UTC
Read the first 4 bytes of the Java class file and output CAFEBABE
[Java] Appropriate introduction by the people of Tempa Java Part 0 (Code rules)
From fledgling Java (3 years) to Node.js (4 years). And the impression of returning to Java
I tried to summarize the methods of Java String and StringBuilder
[Java] Introduction