1. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class A
{
public static void main(String[] args)
{
int[] x = {10, 20, 30};
//Simple Loop
for(int i = 0; i < x.length ; i++)
{
System.out.print(x[i] + " ");
}
}
}
2. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class B
{
public static void main(String[] args)
{
//For Each Loop
int[] x = {10, 20, 30};
for(int i : x)
{
System.out.print( i + " ");
}
}
}
3. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class C
{
public static void main(String[] args)
{
double[] x = {10.9, 23.5, 77.5, 34.5, 66.77};
for(double i : x)
{
System.out.print( i + " ");
}
}
}
4. Program
//Find what it gives Compiletion Error / Compiletion Successfully / Output ?
class E
{
public static void main(String[] args)
{
double[] x = {10.9, 23.5, 77.5, 34.5, 66.77};
for(double i : x)
{
System.out.print( i + " ");
}
System.out.println();
System.out.print("......");
System.out.println();
for(int i = 1; i<4 ; i++)
{
System.out.print( x[i] + " ");
}
}
}