4 Using MWArra y Classes
Use either of the following prototypes for the getShort method, where index
can be of type int or int[]:
public short getShort(int index)
public short getShort(int[] index)
getByte. This method returns the real part of the MWNumericArray element
located at the specified one-based index or index array. The return value is
given type
byte.
Use either of the following prototypes for the
getByte method, where index
can be of type int or int[]:
public byte getByte(int index)
public byte getByte(int[] index)
Example — Getting a Short Value from a Numeric Array
The following examples use this array:
short[][] Adata = {{ 1, 2, 3, 4, 5, 6},
{7, 8,9,10,11,12},
{13, 14, 15, 16, 17, 18}};
MWNumericArray A = new MWNumericArray(Adata, MWClassID.INT16);
int[] index = {2, 4};
System.out.println("A(2,4) = " + A.getShort(index));
When run, the example displays this output:
A(2,4) = 10
Example — Using get and set on a Numeric Array
Given the same MWNumericArray used in the previous example, get and t hen
modify the value of eleme nt (
2, 3):
int[] idx = {2, 3};
System.out.println("A(2, 3) is " + A.get(idx).toString());
System.out.println("");
4-78
Komentarze do niniejszej Instrukcji