Java Program on Anonymous Array
Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
package dataflair;
class TestA
{
void display(int ar[])
{
for(int m:ar)
System.out.println(m);
}
}
class TestB
{
void fact(int n)
{
int f=1;
while(n!=0)
{
f=f*n;
n--;
}
System.out.println("Factorial is "+f);
}
}
public class TestMain7
{
public static void main(String[] args)
{
TestA T=new TestA();
//int a[]={10,20,40,50,70,80};
T.display(new int[]{10,20,40,50,70,80});
TestB T1=new TestB();
T1.fact(7);
new TestB().fact(5);
}
}Did you like our efforts? If Yes, please give DataFlair 5 Stars on Google

