mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-07 23:37:32 +02:00
[java/en] Final Methods
Explained Final Methods
This commit is contained in:
@@ -406,7 +406,7 @@ class Bicycle {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function Syntax:
|
// Method Syntax:
|
||||||
// <public/private/protected> <return type> <function name>(<args>)
|
// <public/private/protected> <return type> <function name>(<args>)
|
||||||
|
|
||||||
// Java classes often implement getters and setters for their fields
|
// Java classes often implement getters and setters for their fields
|
||||||
@@ -604,6 +604,19 @@ public final class SaberToothedCat extends Animal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Final Methods
|
||||||
|
public abstract class Mammal()
|
||||||
|
{
|
||||||
|
// Final Method Syntax:
|
||||||
|
// <access modifier> final <return type> <function name>(<args>)
|
||||||
|
|
||||||
|
// Final methods, like, final classes cannot be overridden by a child class,
|
||||||
|
// and are therefore the final implementation of the method.
|
||||||
|
public final boolean isWarmBlooded()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## Further Reading
|
## Further Reading
|
||||||
|
Reference in New Issue
Block a user