How to Print array values:-
public class arr_console
{
public static void main(String[] args)
{
int i;
String[] name=new String[4];
name[0]="MY NAME";
name[1]="IS";
name[2]="BALWANT";
name[3]="SINGH";
for(i=0;i<name.length;i++)
{
System.out.println(name[i]);
}
}
}
As mentioned above we have created an array with length 4.
It will store four String values.And there is use of for loop to retrieve all the values of array.
No comments:
Post a Comment