I am studying the Java and
I am studying about concept of class type of class
For example,
in the Print.java
public class Print{
public ArrayList<data> list;
public Print(){
list = new ArrayList<data>();
}
public void printIndexList() {
for (data index : list) {
System.out.format("\", index.name)
}
for (String definition : b.def) {
System.out.format("%-6s", definition);
}
}
and In the data.java
public class data{
public String name
public ArrayList<String> def;
public data(){
def = new ArrayList<String>();
}
}
And, in the main.java,
I have String type ArrayList “defmain” and String type “mainname”
I would like to add the defmain and mainname in the list because I need to use printing function in the b.java
What I tried to do way
in the main.java, I have created: –
Print ia = new ptiny();
Array<Print> mainlist = new Array<Print>();
and.. tried to assign value in the list in the a.java
ia.list = mainlist;
however, it didn’t really work.
does anybody know a way to add a string value and an arraylist in the Arraylist which has type “a”?
thanks
Note that class names should start with uppercase letters. The following should work:
Note that I’m not assigning any list. I’m adding elements to lists.