how to assign values to (args) from Jcreator
hi
how to assign values to (args) from Jcreator
Code java:
public static void main(String [] args)
{
double radius;
if (args.length > 0)
{
Circle3 []c1 =new Circle3[(args.length)-1];
for (int i=0;i<args.length;i++)
{
c1[i] = new Circle3(Double.parseDouble(args[i]));
System.out.println("obj("+(i+1)+").Area= "+c1[i].area());
System.out.println("obj("+(i+1)+").Circumferance= "+c1[i].circum());
System.out.println("obj("+(i+1)+").Diameter= "+c1[i].diam());
}
}
Re: how to assign values to (args) from Jcreator
Go to run configurations and then to arguements. That'll get it from Eclispe. not sure from JCreator.
Re: how to assign values to (args) from Jcreator
The way it is now , your for loop will run out of bounds at the invalid index of args.length.
Circle3 []c1 =new Circle3[(args.length)-1];
should be
Circle3[] c1 = new Circle3[args.length];
the number in the brackets is the number of elements.
The way it is, your for loop will run out of bounds at the invalid index of args.length.