1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C#メインの私がJavaを勉強するためのメモ

Posted at

##final = sealed
###Classes

sample.java
public final class MyFinalClass {...}
sample.cs
public sealed class MyFinalClass {...}

###Method
Prevent overriding of a virtual method.

sample.java
public class MyClass
{
    public final void myFinalMethod() {...}
}
sample.cs
public class MyClass : MyBaseClass
{
    public sealed override void MyFinalMethod() {...}
}

###Variables
To only allow a variable to be assigned once:

sample.java
public final double pi = 3.14; // essentially a constant
sample.cs
public readonly double pi = 3.14; // essentially a constant
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?