In k&b book, its said that when using anonymous array, you do not use array size.
for example:
int[] anonymousArray;
new int[3]{someVal1, someVal2, someVal3}; // is illegal
but if i do this,
new int[2]; // it works fine.
So what is the catch?? Is it illegal to define size or recommended not to define?
I used as following:
public class MyAnonymous{
public void testMethod1(){
testMethod2(new int[2][]);
}
public void testMethod2(int[][] b){
...
}
public void main(Strings args[]){
//call to testMehtod1()
}
}
As far i understood if you define size and also use number of items {val1,val2} it does not compile.
Any idea guyz/gals??
- Sarah