I can write:
AClass[] array = {object1, object2}
I can also write:
AClass[] array = new AClass[2];
...
array[0] = object1;
array[1] = object2;
but I can't write:
AClass[] array;
...
array = {object1, object2};
Why is this blocked by Java?
I know how to work around it, but from time to time it would be simpler.
For example:
public void selectedPointsToMove(cpVect coord) {
if (tab == null) {
if (arePointsClose(coord, point1, 10)) {
cpVect[] tempTab = {point1};
tab = tempTab;
} else if (arePointsClose(point2, coord, 10)) {
cpVect[] tempTab = {point2};
tab = tempTab;
} else {
cpVect[] tempTab = {point1,point2};
tab = tempTab;
}
}
}
This simple question that has been bugging me since I learned how to play with arrays in Java.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…