Question

I have a java method one of whose arguments is a 2 dimensional byte array (byte[][]). I wanted to call that method from RPG. I know that it works for one dimensional byte array e.g. by declaring that argument in RPG as nA where n is the length of the array and A is Alphabetic. i.e. nA in RPG is same as byte[] in java. However when I add DIM(k) to the argument declaration RPG, it says Keyword is not allowed in a prototype of a method. I could do it using String data type but I wanted to avoid data type conversions like from bytes to java String and vice-versa. (efficiency issues)

Can anyone help me with getting it work, please?

No correct solution

OTHER TIPS

I think that the way to go here from a code-compileability and readability perspective is to use a simple data-wrapper class holding a one-dimensional array, and then let your main-code use a one-dimensional array of instances of said data-wrapper class.

public class MyBytePacket
{
    private byte [] data;

    //Constructors and getters as needed
}

And then from main code;

MyBytePacket [] packets = new MyBytePacket[10];

That way, you can see how many packets you have, as well as how many bytes each packet has, keeping your desired 2D-aspect, but in a more Java-friendly manner.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top