NOTE:-
As soon as JVM activities {} it makes an things with the provides in {} and designates the deal with of the item to a varying.
In this way we can make range item of all basic information types
In a identical way we can determine arrays of things of classes
The following system illustrates this concept
class Ademo3
{
community fixed gap primary (String args [])
{
A a1 [] = new A[3];
Program.out.println(a1 [0]' // a1 [0] = null
a1 [0] =new A ();
Program.ou.println(a1 [0]); // deal with is printed
a1 [0].i=10
a1 [0].j=20;
a1 [0]. operate A();
A1[1]=a1[0];
Program.out.println(a1[1].i);// 10 is printed
a1[2] = new A ();
}
}
NOTE:-
int i [] =....is same as int [] I =....
// Another example program
category Ademo4
{
community fixed gap primary (string args [])
{
sequence s1 []; // zero is printed
s1 [0] = "java";
Program.out.println(s1 [0]; // coffee is printed
s1 [1] = "abc";
s2 [2] ="xyz";
Program.out.println (s1); // make deal with of range objectof kind String
Program.out.println (s1 [2]); // xyz is printed
}
}
// Another example program
Training Ademos
{
int i=0;
community fixed gap primary (string args [])
{
sequence s1 ]={"abc","xyz",MSD","SSA"};
Ademos a1[]={ new Ademo(), new Ademos(), new Ademo()
};
Program.out.println (s1.lenght); // 4 is printed
Sustem.out.println (s1 [3]); // SSA is printed
a1[0].i = 11;
Program.out.println (a1[1].i); // 0 is printed
}
}
No comments:
Post a Comment