제가 상기 코드 getNumber에NullPointerException이 동안
public static void main(String[] args) throws IOException {
length=getNumber("Enter the length of the field: ");
breadth=getNumber("Enter the breadth of the filed: ");
node n = new node();
node [][] field = new node[length][breadth];
for(i=0;i<=length;i++){
for(j=0;j<=breadth;j++){
F =getNumber("Enter the F value");
field[i][j].setF(F);
System.out.println(" "+field[i][j].getF(F);
}
}
}
다음과 같이 "노드"객체들의 2 차원 어레이를 만들려고하면 나 인쇄 허용 상기 함수
public class node {
public int F;
public int G;
public int H;
public boolean isVisited;
public boolean isCurrent;
public void node(int F,int G,int H,boolean isVisited, boolean isCurrent){
this.F=F;
this.G=G;
this.H=H;
this.isVisited=isVisited;
this.isCurrent=isCurrent;
}
public int getF() {
return G+H;
}
public void setF(int f) {
F = f;
}
public int getG() {
return G;
}
public void setG(int g) {
G = g;
}
public int getH() {
return H;
}
public void setH(int h) {
H = h;
}
public boolean isVisited() {
return isVisited;
}
public void setVisited(boolean isVisited) {
this.isVisited = isVisited;
}
public boolean isCurrent() {
return isCurrent;
}
public void setCurrent(boolean isCurrent) {
this.isCurrent = isCurrent;
}
}
내가하고 싶은 모든이, 저장/각각 F, G, H 등의 액세스 다양한 값 : 숫자 여기 내 노드 클래스 그러나 노드 객체의 문제는 내가 받고있다 field[i][j].setF(F);
나는 어디서 잘못 가고 있는지 알지 못한다. 도움이 필요하다.
나는 그것으로 채우는가?그 객체의 배열 (나는 그것에 매우 정성스럽게 초보자이다) – md1hunox
@vineetrok 내가 정련하는 나의 대답의 바닥 부분을 조사한다. – hvgotcodes
고마워, 지금 일하고 – md1hunox