Skip to content

Instantly share code, notes, and snippets.

@toshimasa-nanaki
Created December 9, 2018 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshimasa-nanaki/4aa8348ea80c5e368e496a71be2ee5ec to your computer and use it in GitHub Desktop.
Save toshimasa-nanaki/4aa8348ea80c5e368e496a71be2ee5ec to your computer and use it in GitHub Desktop.
Rust メソッド構文(Java説明用)
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