class{
public HashMap<String, String> eachperson;
apple(){
this.eachperson.put("thekey","thevalue");
}
}
(.. 난 그냥 내가 제대로 해시 맵을 가하고있어 알고 싶은 클래스와 기능의 앞에 공공/음부를 용서하십시오)이 Java 코드의 문제점은 무엇입니까? 왜 HashMap을 넣을 수 없습니까?
, 아래를 참조하십시오 :
를class ParsedDataSet{
public HashMap<String, String> eachperson;
public List<HashMap<String,String>> peoplelist = new ArrayList<HashMap<String,String>>();
}
class ListprofileHandler extends DefaultHandler{
private boolean in_results = true;
private boolean in_item = false;
private boolean in_first_name = false;
private boolean in_last_name = false;
private boolean in_picture_url = false;
private boolean in_enditem_dummy = false;
private ParsedDataSet dset = new ParsedDataSet();
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
if(localName.equals("results")){
this.in_results = true;
}else if(localName.equals("item")){
this.in_item = true;
}else if(localName.equals("first_name")){
this.in_first_name = true;
}else if(localName.equals("last_name")){
this.in_last_name = true;
}else if(localName.equals("picture_url")){
this.in_picture_url = true;
}else if(localName.equals("enditem_dummy")){
this.in_enditem_dummy = true;
}
}
public void endElement(String uri, String localName, String qName)throws SAXException {
if(localName.equals("results")){
this.in_results = false;
}else if(localName.equals("item")){
this.in_item = false;
}else if(localName.equals("first_name")){
this.in_first_name = false;
}else if(localName.equals("last_name")){
this.in_last_name = false;
}else if(localName.equals("picture_url")){
this.in_picture_url = false;
}else if(localName.equals("enditem_dummy")){
this.in_enditem_dummy = false;
}
}
public void characters(char ch[], int start, int length) throws SAXException {
if(this.in_first_name){
dset.eachperson.put("first_name", new String(ch, start, length));
}
if(this.in_enditem_dummy){
dset.peoplelist.add(dset.eachperson);
dset.eachperson = new HashMap<String,String>(); //Reached a new item. So reset the temporary hashmap.
}
}
public ParsedDataSet getParsedListData(){
return this.dset;
}
}
무엇이 오류입니까? 그냥 "왜 내가 왜 안되니?"라고 말하지 마라. – gubby
나는 안드로이드를하고 있기 때문에 나는이 오류를 알지 못한다. 그리고이 이상한 편집 소스 일을 팝업한다. – TIMEX
이클립스 또는 뭐든간에 새 프로젝트를 만들고 컴파일러에서 무엇을 말하는지 확인하십시오. 추가 오류가 발생할 수 있지만 해시 맵에 대해 설명하는 코드를 찾으십시오. 아마도 런타임 환경 (아마도)과 관련이있을 수 있습니다. – ant