fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3. Point p = new Point(3, 5);
  4. System.out.printf("p.x: %d, p.y: %d%n", p.x, p.y);
  5. }
  6. }
  7.  
  8. class Point {
  9. // フィールド
  10. int x; // X座標
  11. int y; // Y座標
  12.  
  13. // コンストラクタ
  14.  
  15. Point() {
  16. }
  17.  
  18. Point(int px, int py) {
  19. setX(px);
  20. setY(py);
  21. }
  22.  
  23. // メソッド
  24.  
  25. void setX(int px) { // X座標を設定する
  26. x = px;
  27. }
  28.  
  29. void setY(int py) { // X座標を設定する
  30. y = py;
  31. }
  32.  
  33. int getX() { // X座標を得る
  34. return x;
  35. }
  36.  
  37. int getY() { // Y座標を得る
  38. return y;
  39. }
  40. }
  41.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty