急,在线等,求JAVA编程大神
2个回答
展开全部
public class Test {
public static void main(String[] args) {
A a = new A(2, 3);
System.out.println(a.getSum());
}
}
class A {
private int i;
private int j;
public A() {
this(0, 0);
}
public A(int i, int j) {
this.i = i;
this.j = j;
}
public int getI() {
return i;
}
public void setI(int i) {
this.i = i;
}
public int getJ() {
return j;
}
public void setJ(int j) {
this.j = j;
}
public int getSum() {
return i + j;
}
}
展开全部
Class A{
private int i;
private int j;
public A(){
i=0;
j=0;
}
public A(int i,int j){
this.i=i;
this.j=j;
}
public int geti(){
return i;
}
public int getj(){
return j;
}
public void seti(int i){
this.i=i;
}
public void setj(int j){
this.j=j;
}
public int add(){
return (i+j);
}
}
Class Test{
public static void main(String[] args){
A a=new A(2,3);
System.out.println(a.add());
}
}
请采纳谢谢(顺便一提,考试作弊不好)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询