몇 가지 다른 게시물을 검색했지만 정확한 문제를 발견하지 못했습니다. 내가 잃어버린 것은 매우 분명해야하지만 어떤 이유로 든 그것을 완전히 고정시킬 수는없는 것처럼 느껴진다. 누구든지 저에게 손을 줄 수 있다면 크게 감사하겠습니다. 이 프로그램은 텍스트 파일에서 집 정보를 가져 와서 출력합니다. JMUnit7 파일은 강사가 우리에게주었습니다. JMUnit7House 파일이 제 작품입니다. 미리 감사드립니다. "주"java.lang.RuntimeException가 스레드에서 예외 : Uncompilable 소스 코드 - 잘못된 SYM 유형 : 점점 메신저와 잘못된 SYM 유형의 오류가 다음과 같이잘못된 기호 유형
package jmunit7;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
/**
*
* @author Xephus
*/
public class JMUnit7 {
/**
* @param args the command line arguments
* @throws java.lang.Exception
*/
public static void main(String[] args) throws Exception
{
Scanner stdIn = new Scanner(System.in);
Scanner stdInFile = new Scanner(new
File("JMUnit7House.txt"));
JMUnit7House house1, house2; //New houses
//Create house 1 using default constructor
house1 = new JMUnit7House();
house1.print(); //print house 1 with default values
String street, city, state, zipCode;
int number;
System.out.println("Importing Number.");
number = stdInFile.nextInt();
stdInFile.nextLine();
System.out.println("Importing Street.");
street = stdInFile.nextLine();
System.out.println("Importing City.");
city = stdInFile.nextLine();
System.out.println("Importing State.");
state = stdInFile.nextLine();
System.out.println("Importing ZipCode.");
zipCode = stdInFile.nextLine();
System.out.println();
//use method call chaining to set values
//and print results for house 1
house1.setNumber(number).setStreet(street)
.setCity(city).setState(state)
.setZipCode(zipCode).print();
System.out.println("Importing Number.");
number = stdInFile.nextInt();
stdInFile.nextLine();
System.out.println("Importing Street.");
street = stdInFile.nextLine();
System.out.println("Importing City.");
city = stdInFile.nextLine();
System.out.println("Importing State.");
state = stdInFile.nextLine();
System.out.println("Importing ZipCode.");
zipCode = stdInFile.nextLine();
System.out.println();
//create house 2 using 5 parameter constructor
house2 = new JMUnit7House(number,
street, city, state, zipCode);
//print house 2
house2.print();
}
}
내 코드는 .setCity.setState.setZipCode.print jmunit7.JMUnit7.main (JMUnit7.java:49) 49는 house1.setNumber 행입니다.
public class JMUnit7House {
private int number;
private String street;
private String city;
private String state;
private String zipCode;
public JMUnit7House()
{
number = 0;
street = "No Street";
city = "No City";
state= "No State";
zipCode = "No Zip Code";
}
//intializes house with arguments
public JMUnit7House(int number, String street, String city, String state, String zipCode)
{
this.number = number;
this.street = street;
this.city = city;
this.state = state;
this.zipCode = zipCode;
}
public int setNumber(int number)
{
return number;
}
public String setStreet(String street)
{
return street;
}
public String setCity(String city)
{
return city;
}
public String setState(String state)
{
return state;
}
public String setZipCode(String zipCode)
{
return zipCode;
}
//function to print
public void print()
{
String info=String.format("House: %d\n", number);
info += String.format("Street: %s\n", street);
info += String.format("City: %s\n", city);
info += String.format("State: %s\n", state);
info += String.format("Zip: %s\n", zipCode);
System.out.println(info);
}
}
될 및 IDE에 그 라인에있는 코드 오류가 dereferanced 수 없습니다 INT는 – GurV
프로젝트를 다시 빌드합니다. –
코드에서 정확히 어느 라인에서? – GurV