System.out.println(intervals)
will call .toString()
method of the object you are trying to print, which is List.
In order to print every object you have to override the toString()
method for Interval
or print specific value.
for (Inteval interval : intervals) { System.out.println(interval.getValue());}
or if you override the toString()
method for Interval
for (Inteval interval : intervals) { System.out.println(interval);}
You can override the toString()
as follows:
public class Interval {
public int value;
public String val;
@Override
public String toString() {
return "Value string: " + val + " value int: " + value;
}
}