I'm trying to create a table(2d)in which each cell consist of a value and key(created an object for this) but i'm having trouble in placing a value to the object from the ArrayList
.
Incompatible types:
String
cannot be converted toint
public static void Con(){
ArrayList<Content> arrList1 = new ArrayList<Content>();
ArrayList<ArrayList> arrList2 = new ArrayList<ArrayList>();
//Content yeah = new Content("asdfas","asdfasdf");
for(Content a: arrList1)
//arrList1.add(Content a = new Content("asdf","fasd"));
arrList1.add("oh","yeah");
//arrList1.ge
}
Here is the object class
public class Content extends Object{
private String key;
private String value;
private String keyVal;
public Content (String key, String value) {
this.key = key;
this.value = value;
}
public String getKey() {
return key;
}
public String getValue() {
return value;
}
public String getKeyValue(){
return key+value;
}
public void display(){
System.out.println(this.key+","+this.value);
}
}
I already figured it out. I used:
arrList1.add(new Content("9","9"));
Sorry for the trouble
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.