Integration and Testing

Authorize.Net API questions and help with your payment integration.

Reply
New Member
Posts: 3
Registered: ‎01-08-2022

How to do the designing of an array in rest api

[ Edited ]

import java.lang.reflect.Array;

import java.util.Arrays;

 

import javax.ws.rs.GET;

import javax.ws.rs.Path;

import javax.ws.rs.PathParam;

import javax.ws.rs.Produces;

import javax.ws.rs.core.MediaType;

 

import netscape.javascript.JSObject;

 

u/Path("PerfectNumber/{a},{b}")

u/Produces(MediaType.TEXT_PLAIN)

public class PerfectNo {

 

u/GET
public static int[] isPerfectNumber(@PathParam("a") int starting_number, u/PathParam("b") int ending_number)

{

int array\[\] = null;

int sum = 0;
int i;

for ( i=starting\_number; i<=ending\_number; i++)
{

for (int j=1 ; j<=i-1;j++)

{

if (i % j==0)

{

sum=sum+j;

}

}

if (sum==i)

{

array[array.length]=sum;

}

}

return array;

}

}