Java Reference
In-Depth Information
Otherwise, the reference value of the right-hand operand is stored into the se-
lected array component.
Otherwise, three steps are required:
• First, the left-hand operand is evaluated to produce a variable. If this evaluation
completes abruptly, then the assignment expression completes abruptly for the
same reason; the right-hand operand is not evaluated and no assignment occurs.
• Otherwise, the right-hand operand is evaluated. If this evaluation completes ab-
ruptly, then the assignment expression completes abruptly for the same reason and
no assignment occurs.
• Otherwise, the value of the right-hand operand is converted to the type of the left-
hand variable, is subjected to value set conversion (§ 5.1.13 ) to the appropriate
standard value set (not an extended-exponent value set), and the result of the con-
version is stored into the variable.
Example 15.26.1-1. Simple Assignment To An Array Component
Click here to view code image
class ArrayReferenceThrow extends RuntimeException { }
class IndexThrow extends RuntimeException { }
class RightHandSideThrow extends RuntimeException { }
class IllustrateSimpleArrayAssignment {
static Object[] objects = { new Object(), new Object() };
static Thread[] threads = { new Thread(), new Thread() };
static Object[] arrayThrow() {
throw new ArrayReferenceThrow();
}
static int indexThrow() {
throw new IndexThrow();
}
static Thread rightThrow() {
throw new RightHandSideThrow();
}
static String name(Object q) {
String sq = q.getClass().getName();
int k = sq.lastIndexOf('.');
return (k < 0) ? sq : sq.substring(k+1);
}
static void testFour(Object[] x, int j, Object y) {
String sx = x == null ? "null" : name(x[0]) + "s";
String sy = name(y);
System.out.println();
Search WWH ::




Custom Search