Hello, I know this is a very basic question but I would appreciate so help in determining why my constructor is not creating an array for me.
Here is the code:
Also,
public class DoubleArraySeq {
private double[] data;
private int manyItems;
private int currentIndex;
public DoubleArraySeq() {
super();
final int INITIAL_CAPACITY = 10;
manyItems = 0;
data = new double [INITIAL_CAPACITY];
}
public String toString(){
StringBuffer buffer = new StringBuffer();
buffer.append("Scores: [");
for (double item : data){
buffer.append(item + " ");
}
buffer.append("]");
return buffer.toString();
}
Here is the code:
public static void main(String[] args) {
DoubleArraySeq sequence;
sequence = new DoubleArraySeq();
for(int i = 0; i < sequence.length; i++){
sequence[i] = i;
}
sequence.toString();
}
}
Also,
public class DoubleArraySeq {
private double[] data;
private int manyItems;
private int currentIndex;
public DoubleArraySeq() {
super();
final int INITIAL_CAPACITY = 10;
manyItems = 0;
data = new double [INITIAL_CAPACITY];
}
public String toString(){
StringBuffer buffer = new StringBuffer();
buffer.append("Scores: [");
for (double item : data){
buffer.append(item + " ");
}
buffer.append("]");
return buffer.toString();
}
public class DoubleArraySeq {
private double[] data;
private int manyItems;
private int currentIndex;
public DoubleArraySeq() {
super();
final int INITIAL_CAPACITY = 10;
manyItems = 0;
data = new double [INITIAL_CAPACITY];
}
public String toString(){
StringBuffer buffer = new StringBuffer();
buffer.append("Scores: [");
for (double item : data){
buffer.append(item + " ");
}
buffer.append("]");
return buffer.toString();
}