Created
December 9, 2018 04:51
-
-
Save toshimasa-nanaki/4aa8348ea80c5e368e496a71be2ee5ec to your computer and use it in GitHub Desktop.
Rust メソッド構文(Java説明用)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Circle { | |
private double radius; | |
Circle(double radius){ | |
this.radius = radius; | |
} | |
public double area(){ | |
return Math.PI * (this.radius * this.radius); | |
} | |
} | |
class Main { | |
public static void main(String[] args){ | |
Circle c = new Circle(2.0); | |
System.out.println("area is " + c.area()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment