Java Reference
In-Depth Information
3
4
The
I
in
[I@3e25a5
indicates that this is a reference to an array of integers.
The forefront letter varies according to the type of array elements as illustrated
by the following code:
Program 4.5
Printing the references of various typed arrays
class
ArrayDisplay
{
public static void
main ( String [ ] args )
int
[] x=
new i n t
[10]; System.out. println(x);
double
[] y=
new double
[20]; System.out. println(y);
float
[] z=
new f l o a t
[5]; System.out.println(z);
boolean
[] b=
new boolean
[7];System.out.println(b);
}
}
We get
3
:
[I@3e25a5
[D@19821f
[F@addbf1
[Z@42e816
v
type
length
[I
6
2
3
1
2
7
1
0
1
2
3
4
5
Figure 4.1
A way to visualize arrays in
Java, explained for the array declaration and
assignment:
int
[] v =
{
2,3,1,2,7,1
}
;
.
One way to depict arrays is shown in Figure 4.1. Note that the length and type
of the array are indicated in this representation (reflexive arrays).
3
Anarrayofstringshastype
[Ljava.lang.String;
Search WWH ::
Custom Search