Java Service Developer Issue

Hello, i have the next problem i would like if anyone can help me.

The array “a” is full it with random numbers that i generate in another method call “dice”, the problem is that i can’t get the output to work. When i run it, the output is a code o something for example= [I@5e8a49

this are the input and out of the java service:

input: cant(integer)
out: glass (integer list)

this the code of the java service on the devepoler ide.
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();

int cant = IDataUtil.getInt( pipelineCursor, “cant”, -1 );

int a =new int[cant];

for(int i =0; i < a.length ; i++){
a[i]=dice();

}

IDataUtil.put( pipelineCursor, “glass”, a );
pipelineCursor.destroy();

any idea?

I have to agree i did not completely understand what you were asking for, As far as i understood from your above post looks like you are having issue printing out the integer list from dice method, is that right? Hope this helps!

IDataCursor pipelineCursor = pipeline.getCursor();
        Integer cant = (Integer)IDataUtil.get( pipelineCursor, "cant" );
        pipelineCursor.destroy();
        
        List<Integer> tempOutput=new ArrayList<Integer>();        
        tempOutput=dice(cant);
        
        IDataUtil.put(pipelineCursor, "glass", tempOutput.toArray(new Integer[tempOutput.size()]));        

Shared:

private static List<Integer> dice(Integer count){
        
        Random randomGenerator = new Random();
        List<Integer> temp=new ArrayList<Integer>();        
        
        for(int i=0;i<=count-1;i++){
            int randomInt = randomGenerator.nextInt(100);
            temp.add(randomInt);
        }
        return temp;        
    }

Cheers,
Akshith

Thanks you Akshith. i going to test it, i then i will tell if it works.

The original code is working. It is correctly generating an array of integers (assuming the dice() method is accessible somewhere

What you’re seeing in the results pane is the JVM address of the array itself–[strike]Developer doesn’t convert arrays of anything to strings for you. If that’s what you want, then you need to convert the array of integers to an array of strings.
[/strike]
Based upon the post from akki_84 below, the statement I made above is wrong. Thanks akki_84 for showing the code and the screen shots.

Hello today i tested it and i modify a little your code, but i didn’t get it work, i need make the service to show me all the values in the list (that i full it with ten random numbers), but it only show one value in the result panel, could you help me, please

IDataCursor pipelineCursor = pipeline.getCursor();
Integer cant = (Integer)IDataUtil.get( pipelineCursor, “cant” );

    List<Integer> tempOutput=new ArrayList<Integer>();  
for(int i=0;i < 10 ; i++){
	tempOutput.add(dice());
}      

IDataUtil.put(pipelineCursor, “glass”, tempOutput.toArray(new Integer[tempOutput.size()]));

pipelineCursor.destroy();

Hello, yes i need the full result from the list, so i can seeing in the result pane, but i only see one value. if you know the solution please let know. thank you.

I think there might be an issue with your dice method, can you please post it here? The changes that you made should have added all the outputs from the dice method to the outlist and an Integer list (glass) should have been generated as output.

Cheers,
Akshith

public static int dice(){

int dice= (int) (Math.random()*6+1);


return dice;

}

Hmm that looks good, Can you please create a new java service with the following signature? A service with below details is working fine for me.

Inputs:
None (no inputs)

Outputs:
glass(Integer List)

[ATTACH=CONFIG]911[/ATTACH]

IS Code:

IDataCursor pipelineCursor = pipeline.getCursor();
        List<Integer> tempOutput=new ArrayList<Integer>(); 
        for(int i=0;i < 10 ; i++){
        tempOutput.add(dice());
        } 
        
        IDataUtil.put(pipelineCursor, "glass", tempOutput.toArray(new Integer[tempOutput.size()]));        
        pipelineCursor.destroy();

Shared Code:

public static int dice(){
    
        int dice= (int) (Math.random()*6+1);
        return dice;
    }

untitled.jpg

I copy your code that you post and finnally it work, i didn’t see the result below the glass integer list my fault, thank you very much!

Glad could help!

Cheers,
Akshith