小编You*_*f N的帖子

加错答案

public class Container {
    private int value;
    public Container(int value){
        this.value=value;
    }
    public int getValue(){
        return this.value;
    }
    public int sum(Container c){
        return this.value+c.getValue();
    }
    public void main(){
        Container c1=new Container(1);
        Container c2=new Container(2);
        System.out.println("sum: " + c1.getValue()+c2.getValue());
        System.out.println("sum: " + c1.sum(c2));
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我得到以下结果:

public class Container {
    private int value;
    public Container(int value){
        this.value=value;
    }
    public int getValue(){
        return this.value;
    }
    public int sum(Container c){
        return this.value+c.getValue();
    }
    public void main(){
        Container c1=new Container(1);
        Container c2=new Container(2);
        System.out.println("sum: …
Run Code Online (Sandbox Code Playgroud)

java oop object

7
推荐指数
1
解决办法
52
查看次数

标签 统计

java ×1

object ×1

oop ×1