zoukankan      html  css  js  c++  java
  • 创建一个Point类,有成员变量x,y,方法getX(),setX(),还有一个构造方 法初始化x和y。创建类主类A来测试它。

    package com.homework.zw;
    
    public class Point {
        private int x;
        private int y;
    
        Point(int x, int y) {
            this.x = x;
            this.y = y;
        }
    
        public int getX() {
            return x;
        }
    
        public void setX(int x) {
            this.x = x;
        }
    
        public int getY() {
            return y;
        }
    
        public void setY(int y) {
            this.y = y;
        }
    
    }
    package com.homework.zw;
    
    public class A {
    
    	public static void main(String[] args) {
            Point po=new Point(25,30);
            System.out.println("x="+po.getX()+"  y="+po.getY());
            po.setX(200);
            po.setY(250);
            System.out.println("x="+po.getX()+"  y="+po.getY());
    	}
    
    }
    

      

  • 相关阅读:
    vmalloc详解
    SSD 页、块、垃圾回收
    ext2文件系统
    slub分配object
    slab分配object
    ACCESS_ONCE的作用
    CFS理论模型
    代码规范
    About Me
    SDOI R2 咕咕记
  • 原文地址:https://www.cnblogs.com/HRZJ/p/5886489.html
Copyright © 2011-2022 走看看