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?"
(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.");
}
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
"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