Class/220728
Class 예제(1-2)
by pms93
2022. 7. 28.
package constructor;
import java.util.ArrayList;
public class Reverse {
private int data, result;
public Reverse() {}
public Reverse(int data) {
this.data = data;
}
public int getData() {
return data;
}
public void setData(int data) {
this.data = data;
}
public int getResult() {
return result;
}
public void setResult(int result) {
this.result = result;
}
public void reverseResult() {
ArrayList<Integer> tmp = new ArrayList<Integer>();
while (this.data != 0) {
tmp.add(this.data % 10);
this.data /= 10;
}
int powCnt = tmp.size() - 1;
for(int cnt = 0; cnt < tmp.size(); cnt++) {
this.result += tmp.get(cnt) * (Math.pow(10, powCnt));
powCnt--;
}
System.out.println(result);
}
}