[Java] What are overrides and overloads?

I don't know what the output is, but it's a memorandum. Let's do it without thinking too much because it is better than worrying about how to write it.

It's like a slug thrown into the Dead Sea when I was a student in the first year of IT (?) New graduates and had no computer experience. I'm doing Kuromoto because I want to take JavaSE11Silver, but my personal stumbling block is override and overload. confusing. Didn't the person who named it think so? You wouldn't have thought. There is no human heart. There are about 6 characters and 4 characters are the same, so it would be the same in a majority vote.

Simply 【override】 -A redefined method defined in a superclass so that it can be used in a subclass. By the way, the superclass is the inherited side and the subclass is the inherited side. -The return value, method name, and argument must be the same for the overridden side and the overridden side. -For access restriction levels (public, private, abstract, final, etc.), the overriding side must have looser access restrictions than the overriding side. (The overriding side of the superclass cannot be public and the overriding side of the subclass cannot be private.) -Methods with final cannot be overridden. -When the access modifier of the overridden method is abstract, the method must be overridden. If not, the class itself becomes an abstract class. (By the way, what is the abstract class ...)

【Overload】 -Create multiple methods in the same class with the same method name but different arguments, number of arguments, and arrangement. -If the return value, access level, argument name, and throw clause are different, overloading will not be possible and a compile error will occur.

it seems like.

By the way, if you translate each into English Override rides on ... overload makes it overloaded. Loaded with weight. It seems to mean that

I think it's easier to remember if the override is the image of riding on top of the parent class, and the overload is the image of overloading the same method in the class.

Finally, when I'm writing this article, I can see the preview on the right side, but the readability is deadly low.

Recommended Posts

[Java] What are overrides and overloads?
[Java] HashCode and equals overrides
Java methods and method overloads
C # and Java Overrides Story
What are Java metrics? _Memo_20200818
[Java Silver] What are class variables instance variables and local variables?
Java arguments, return values and overloads
[Java] How to use static modifiers (What are static final and static import)
What is Java and Development Environment (MAC)
What are the updated features of java 13
What are JDK, Oracle JDK, OpenJDK, Java SE?
What is java
What is Java <>?
What is Java
Java and JavaScript
XXE and Java
What I learned in Java (Part 2) What are variables?
Getters and setters (Java)
[Java] Thread and Runnable
[Java] Sorting tips when strings and numbers are mixed
Java true and false
[Java] String comparison and && and ||
What is Java Encapsulation?
[JAVA] What is the difference between interface and abstract? ?? ??
[Java] Arguments and parameters
timedatectl and Java TimeZone
What is Java API-java
[Java] Branch and repeat
[Rails] What are params?
[Java] What is flatMap?
[Java] Variables and types
What is the difference between Java EE and Jakarta EE?
[Java] What is JavaBeans?
[Java] What is ArrayList?
[Java] Overload and override
What if the results of sum and inject (: +) are different?
What I learned in Java (Part 4) Conditional branching and repetition
What happened in "Java 8 to Java 11" and how to build an environment
What has changed between Effective Java 2nd Edition and 3rd Edition
What you learned when you acquired Java SE 8 Silver and Gold
Study Java # 2 (\ mark and operator)
What is Java Assertion? Summary.
What I researched about Java 8
Java version 8 and later features
What I researched about Java 6
[Java] Difference between == and equals
[Java] Stack area and static area
[rails] What are Strong Parameters?
Java equals are pretty unpleasant
Java programming (variables and data)
Java encryption and decryption PDF
Java and Iterator Part 1 External Iterator
What I researched about Java 9
Java if and switch statements
What are command line arguments?
Java class definition and instantiation
[Environment variables] What are rails environment variables?
Apache Hadoop and Java 9 (Part 1)
[Java] About String and StringBuilder
What is a Java collection?
☾ Java / Iterative statement and iterative control statement