package apples;
public class apples {
private int sum;
private final int NUMBER ;
public apples(int x) {
NUMBER=x;
}
public void add() {
sum+=NUMBER;
}
public String toString() {
return String.format("sum = %d\n",sum);
}
}
package apples;
public class boy {
public static void main (String []args) {
apples applesObject = new apples(10);
for(int i=0; i<5; i++) {
applesObject.add();
System.out.printf("%s", applesObject);
}
}
}
Comments
Post a Comment