I’m trying to format my output of Marks from 2 different ArrayList
s. One for Homework
, another for Exams
. The format I’m looking for is something like this:
My Code so far is
JavaScript
x
public void example() {
System.out.println("");
System.out.println("Subject: "+subjectString);
System.out.print("Homework Mark: ");
for(int i = 0; i <= arrayList1.size()-1; i++){
System.out.printf("",arrayList1.get(i));
}
}
}
But I cannot get it to work in any way.
Advertisement
Answer
Try this one
JavaScript
public void load() {
System.out.println("");
System.out.println("Subject: "+subjectString);
System.out.print("Homework Mark: t");
for(int i = 0; i < arrayList1.size(); i++){
System.out.print(arrayList1.get(i) + "t");
}
System.out.println("");
System.out.print("Exam Mark: t");
for(int i = 0; i < arrayList2.size(); i++){
System.out.print(arrayList2.get(i) + "t");
}
System.out.println("");
}
using t
will add tabs to organize the output format