View RSS Feed

Java Array

Java arrays.

  1. Array Store Exception

    by , 03-04-2012 at 10:18 AM
    If array variable v consists of type A[] (where A is a reference type) then v might hold a reference to any array type B[] instance.( provided that B could be assigned to A).

    Example:
    Java Code:
    class Point { int x, y; }
    class ColoredPoint extends Point { int color; }
    class Test {
    	public static void main(String[] args) {
    		ColoredPoint[] cpa = new ColoredPoint[10];
    		Point[] pa = cpa;
    		System.out.println(pa[1] == null);
    		try
    ...

    Updated 03-04-2012 at 10:21 AM by Java Array

    Categories
    Exception