3 /**/ 17 39 82 108 117 8 25 47 58 63 72 99
I have these numbers. They read into the field int [][]rag by the program below.
public class RaggedArray {
/**/
private int [][] rag;
/**/
public static void main ( String [] arg ) {
System.out.println( new RaggedArray() );
return;
}
/**/
public RaggedArray() {
initFromFile("rag.txt");
}
/**/
public String toString () {
/**/
String lf;
/*
* lf == line-feed character
*/
lf=System.lineSeparator();
/*
* Provide needed code here.
*/
}
/**/
private void initFromFile ( String fileName ) {
/**/
FileInput fi;
int numRows;
/**/
fi=new FileInput(fileName);
numRows=fi.readLineInt();
rag=new int [numRows][];
fi.readLine();
for ( int i=0; i<numRows; ++i ) rag[i]=fi.readLineInts();
fi.close();
/**/
return;
}
}
This is what I have so far
rag=new int [4][]
for (int i=0; i<rag.length; ++i ) {
Each int is supposed to be right justified in a field of width four. I honestly only know how to do this if the numbers are included in the code. But the numbers are in a different file. Does anyone have any idea?