cloning - Copying Array Dimensions -


I have a method, AMDF (), which takes two object references, a1 and a2, and two string values , Dim1, and dim 2

  public static object aModify (object a1, string dim1, object A2, string dim 2);  

A1 and A2 will be passed as arrays, and dim1 and dim2 as array dimensions (like dim1 = "0", dim2 = "0 0") Will be passed.

The goal behind this method is to take the array a2 on dim2 and copy the value on a1 to dim1.

I've successfully copied two arrays in new examples, manipulated, but I'm really confused to translate the string values ​​into dim1 and dim2 array dimensions, and then copy the values ​​to these dimensions Use to create

So far, for this method I have

  object copy1 = Array.newInstance (a1.getClass (). GetComponentType (), Array.getLength (a1) ); Object copy 2 = array. Experience (a2.getClass (). GetComponentType (), array.tag lamp (A2)); Copy 1 = Mythility. Aclon (A1); Copy 2 = MyUtility. A. Clone (A2);  

aClone () is a method that I wrote that gives a copy of all the array passed in the method.

Array and A1 also have different dimensions Array a1 is a three-dimensional array where a2 is a four-dimensional array.

I'm not sure that your method will be direct to int , But if you are trying to convert the string "0" to int , you simply Integer.parseInt () .

If you want to convert the string "0 0" to two different integers, then you will see the string on each element in the resulting array Use .split () and then integer .parseInt () .

Based on your description of your goal, you probably want something like this?

  int t_dim1 = integer. From the front (dim1); String [] twodims = dim1.split (""); Int t_dim2_1 = integer.print (twodims [0]); Int t_dim2_2 = integer.precent (twists dimensions [1]);  

Update : It appears that OPI wants to handle arbitrary numbers of dimensions. For this, we should be a bit clever. First of all, we write an assistant function.

  int [] parseAndConvert (string dims) {string [] dimArray = dims.split (""); Int [] retVal = new int [dimArray.length]; For (Int i = 0; I & lt; Retribution. Lamp; I ++) R [I] = Integr. Curtor (Damerera [ii]); Return rate; }  

Then, inside aModify , we will need to do something to find the element and set it up. Note that this is unhealthy, but it should be very close to you.

  public static object aModify (object a1, string dim 1, object A2, string dim 2) {int [] dims1 = parseAndConvert (dim1); Int [] dims2 = purse and convert (dim2); // Find the element to copy object copyMe = a1; For (int i = 0; i  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -