다른 클래스에서 HashMap에 사용할 수 있도록 관련 문제는, 내가 잘못 무슨 일이 일어나고 있는지 확실하지 않다 :자바 - 내가 그러나이 현재의 문제에 대한 답을 많이 연구 한
import java.util.Map;
import java.util.HashMap;
public class Items
{
public static void main (String args[])
{
HashMap<String, Double> Hallway = new HashMap<String, Double>();
HashMap<String, Double> Toilet = new HashMap<String, Double>();
HashMap<String, Double> ChemistryLab = new HashMap<String, Double>();
HashMap<String, Double> Outdoors = new HashMap<String, Double>();
HashMap<String, Double> Library = new HashMap<String, Double>();
HashMap<String, Double> Engineering = new HashMap<String, Double>();
HashMap<String, Double> Cafeteria = new HashMap<String, Double>();
HashMap<String, Double> ComputerLab = new HashMap<String, Double>();
HashMap<String, Double> LectureTheater = new HashMap<String, Double>();
HashMap<String, Double> MedicalCentre = new HashMap<String, Double>();
}
public HashMap<String, Double> getHallwayItems()
{
return Hallway;
}
public HashMap<String, Double> getToiletItems()
{
return Toilet;
}
public HashMap<String, Double> getChemistryLabItems()
{
return ChemistryLab;
}
public HashMap<String, Double> getOutdoorItems()
{
return Outdoors;
}
public HashMap<String, Double> getLibraryItems()
{
return Library;
}
public HashMap<String, Double> getEngineeringItems()
{
return Engineering;
}
public HashMap<String, Double> getCafeteriaItems()
{
return Cafeteria;
}
public HashMap<String, Double> getComputerLabItems()
{
return ComputerLab;
}
public HashMap<String, Double> getLectureTheaterItems()
{
return LectureTheater;
}
public HashMap<String, Double> getMedicalCentreItems()
{
return MedicalCentre;
}
}
그것은 말한다 그러나 컴파일을 시도 할 때 변수 Hallway를 찾을 수 없지만 어떻게 해결 될지 알 수 없습니다. 도움을 주셔서 감사합니다.
당신은 [범위] (http://en.wikipedia.org/wiki/Scope_ (computer_science)) – azurefrog
그리고에 대한 표준에 대해 배울 필요가 ... OOPS 악용 Java 명명 규칙. –