내가 자바에 새로운 오전과 나는 코드의 조각을 이해하려고 노력하고 있어요 :다른 메서드 내에서 다른 메서드를 호출합니까?
이public class Image {
...
public float getPixel(int height, int width) {
return data[height][width];
}
public void setPixel(float value, int height, int width) {
if (value > getMax())
value = getMax();
if (value < 0)
value = 0;
data[height][width] = value;
}
private Image(String magicNumber, int height, int width, float max) {
this.magicNumber = magicNumber;
this.width = width;
this.height = height;
this.max = max;
data = new float[height][width];
}
...
public Image clone() {
Image clone = new Image(getMagicNumber(), getHeight(), getWidth(), getMax());
for (int i = 0; i < getHeight(); i++) {
for (int j = 0; j < getWidth(); j++) {
clone.setPixel(getPixel(i, j), i, j); /** trying to understand this line */
}
}
return clone;
}
clone.setPixel(getPixel(i, j), i, j);
정확히 무엇을 하는가를? 그리고 대부분 이해가 안되는 부분은 setPixel(getPixel(i, j), i, j);
전의 clone.
입니다.
하지만'setPixel'은 클래스'Image'에서 왔습니다. 나는 아직도'.clone'이하고있는 것을 이해하지 못한다 ... 다른 말로 설명해 주시겠습니까? –
@JamesH'clone'은'Image'의 기본 요소이며, 그 인스턴스에서'setPixel'을 호출하려고합니다. – Parsa