Thursday, 4 May 2017

Printing array values in java

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

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...