Hello there!
I am new to Java and DW, though I usually find great help already here!
Say I need a constructor that accepts variable number of parameters up to 2 parameters, but if I pass only one parameter to this constructor, both parameters will take this number, and if I passed two parameters, they're treated normally. I tried to do it with only 1 parameter, but my program crashes with:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException:
I think because it's supposed to take 2 params? if so, any idea how can I do that? (to pass only 1 param to a 2 param constructor)
Sample code:
public createTables (int rows, int columns) // Or is it better to do it like (int[][] Table) ?
{
int[][] Table = new int [row][column];
if (Table[column].length < 0) // no second parameter is passed ( is that how to track the second dimension in multi-D arrays?)
column = row;
else
{
row = row;
column = column;
}
}
The above code is just a sample, the real assignment is far too long from this :-/
Thanks in advance!