System.arrayCopy with generics

I am new to generics. Could anybody show me a class/method like System.arrayCopy that would work with any primitive arrays using generics?

Unfortunately, nobody can provide you with a solution that uses generics because the current generics proposal in Java simply does not allow primitive types to be used in generic parameters. Only objects.
Sorry. The answer is that it's impossible, unless the generics team at Sun decides to implement generics completely differently.

Similar Messages

  • Question on System.arraycopy method and multidimensional array

    I'm trying to copy from single dimensional to multidimensional array using System.arraycopy method. The following is my problem.
    1) I need to specify the index of the multidimensional array while copying. Can I do that ? If yes , how???
    eg ; int a[] = new int[3];
    int b[] = new int[3][2]; I need to copy from a to b
    I tired the following and I'm getting an error.
    System.arraycopy(a,0,b[][1],0,3);
    How Can I achieve the above?? PLease Help --------------

    Java doesn't have multidimensional arrays. When you see an int[][] it's an array of arrays of ints. The arrays of ints might have different lengths like this one:int[][] arr =
    {{1,2,3,4},
    {1,2,3},
    {1,2},
    {1}
    };Do I need to say that arraycopy as you see it would fail in this case?
    If you know what kind of arrays you'll have you can simply implement your own arraycopy method (but it will not be as effecient as System.arraycopy) with a simple for-loop.

  • How to create an array with Generic type?

    Hi,
    I need to create a typed array T[] from an object array Object[]. This is due to legacy code integration with older collections.
    The method signature is simple:public static <T> T[] toTypedArray(Object[] objects)I tried using multiple implementations and go over them in the debugger. None of them create a typed collection as far as I can tell. The type is always Object[].
    A simple implementation is just to cast the array and return, however this is not so safe.
    What is interesting is that if I create ArrayList<String>, the debugger shows the type of the array in the list as String[].
    If I create ArrayList<T>, the class contains Object[] and not T[].
    I also triedT[] array = (T[]) Array.newInstance(T[].class.getComponentType(), objects.length);And a few other combinations. All work at runtime, create multiple compilation warnings, and none actually creates T[] array at runtime.
    Maybe I am missing something, but Array.newInstace(...) is supposed to create a typed array, and I cannot see any clean way to pass Class<T> into it.T[].class.getComponentType()Returns something based on object and not on T, and T.class is not possible.
    So is there anything really wrong here, or should I simply cast the array and live with the warnings?
    Any help appreciated!

    Ok. May be you could keep information about generic type in the your class:
    public class Util {
        public static <T> T[] toTypedArray(Class<T> cls, Object[] objects){
            int size = objects.length;
            T[] t = (T[]) java.lang.reflect.Array.newInstance(cls, size);
            System.arraycopy(objects, 0, t, 0, size);
            return t;
    public class Sample<T> {
        Class<T> cls;
        T[] array;
        public Sample(Class<T> cls) {
            this.cls = cls;
        public void setArray(Object[] objects){
            array = Util.toTypedArray(cls, objects);
        public T[] getArray(){
            return array;
        public static void main(String[] args) {
            Object[] objects = new Object[] { new LinkedList(), new ArrayList()};
            Sample<List> myClass = new  Sample<List>(List.class);
            myClass.setArray(objects);
            for(List elem: myClass.getArray()){
                System.out.println(elem.getClass().getName());
    }

  • System.arraycopy (2 dim array) and growth of 2 dim array

    Hi everybody
    I am working on a program which contains a module that can perform Cartesian product on number of sets.
    The code I have developed so far is :
    import java.lang.reflect.Array;
    public class Cart5 {
    public static void main(String[] args) throws Exception
    int pubnewlength;
    // declare SolArray
    int[][] solArray;
    // initialize solArray
    solArray=new int[1][4];
    // Use for method
    for (int ii=0 ; ii<4 ; ii++)
    solver(solArray,ii);
    // Print the array ?
    System.out.println("\n  The array was changed ... " );
    }  // End main
    public void solver(int Solarray2[][] , int abi)
    int[][]  A  =  {  {1,2,3,5},
                      {4,6,7},
                      {11,22,9,10},
                      {17,33}
      jointwoArrays(solarray2,A,abi);
    // some other operations
    } // End Solver method
    public void jointwoArrays(int solarray3[][] , int aArray[][],int indexA)
    int y,u;
    int[][] tempArray;
    // calculate growth of rows:
    pubnewlength=solArray3.length * aArray[indexA].length;
    //Fill TempArray
    y=solArray3[0].length;
    u=solArray3.length;
    tempArray=new int[u][y];
    // Use system.arraycopy to copy solArray3 into tempArray -- How ?
    // Change the size of arrow to proper size -- How ?
    solArray3 = (int[][]) arrayGrow(solArray3);
    // Join operation - Still under construction
    for(int i = 0, k = 0; i < tempArray.length; i++)
                   for(int j = 0; j < set3.length; j++)
                                     for (q=0;q<=2;q++)             
                                      { solArray3[k][q] = tempArray[i][q];}
                                     solArray3[k][q]= aArray[indexA][j];
                                     ++k;
    } // End jointwoArrays method
    // This module is from http://www.java2s.com/ExampleCode/Language-Basics/Growarray.htm
        static Object arrayGrow(Object a) {
        Class cl = a.getClass();
        if (!cl.isArray())
          return null;
        Class componentType = a.getClass().getComponentType();
        int length = Array.getLength(a);
        int newLength = pubnewlength;
        Object newArray = Array.newInstance(componentType, newLength);
        System.arraycopy(a, 0, newArray, 0, length);
        return newArray;
    } // End ClassI deeply appreciate your help with these 3 questions :
    1. How can I use system.arraycopy to copy my two dimensional array? I have searched but examples seem to be about one dim arrays.
    2. How can I change the "static Object arrayGrow(Object a)" , to grow my two dimensional array ?
    3. If you know any codes or articles or java code regarding cartesian products , please tell me.
    Thank you
    Denis

    1. How can I use system.arraycopy to copy my two
    dimensional array? I have searched but examples seem
    to be about one dim arrays.That's because you can't do it in one call. You need to create a loop which copies each 'row".
    >
    2. How can I change the "static Object
    arrayGrow(Object a)" , to grow my two dimensional
    array ?Why do you make it so complicated (generic). Make it take an int[][] array instead, and see the answer from above.
    >
    3. If you know any codes or articles or java code
    regarding cartesian products , please tell me.There are probably lots of them if you google.
    Kaj

  • When I create a New Folder (on the desktop or in Finder), the system uses the Generic Document Icon instead of the Generic Folder Icon. How can I change this back?

    When I create a New Folder (on the desktop or in Finder), the system uses the Generic Document Icon instead of the Generic Folder Icon. How can I change this back?
    All of a sudden I noticed that most of the folders on my computer were no longer using the folder icon, but the generic document icon. I had to manually change back the icon being used by opening Get Info for each folder and copying and pasting the generic folder icon from some folders that remained unchanged. Now whenever I create a New Folder (right click -> "New Folder"), the icon that shows up is the generic document icon (white page with top right corner turned down). And I have to manually change it so it shows up as a folder in Finder or on my desktop. I don't know why or how this switch happened. All of the folders now on my computer look ok, but I need to change the default so when I create a New Folder it uses the correct icon.
    I have also Forced Relaunch of my Finder and rebooted the system. I downloaded Candybar but am not sure what will fix anything, so I haven't proceeded.
    Anyone know how I can do this? Thanks.

    Anyone?

  • Converting enumerations to lists with generics

    hello...
    i want to list off system properties and sort them.
    how can you convert enumerations to lists with generics?
    i tried the following in eclipse, but it fails...
         Properties properties = System.getProperties( ) ;
         Enumeration<?> enumeration = properties.propertyNames( ) ;
         ArrayList<String> arrayListEnum = Collections.list( enumeration ) ;
         Collections.sort( arrayListEnum ) ;

    Because the type parameter of Enumeration (<?>) is not compatible with the type parameter of ArrayList (<String>).
    You'll have to do some manual casting yourself.
    Unfortunately, there's nothing to guarantee that system property keys or values are strings (hence why Enumeration<?> and no Enumeration<String>) so you'll need to cope if you find one that isn't.

  • Program with generics compiles without -source 1.5 but doesn't run.

    This could probably be considered a bug in J2SE1.5 beta 1.
    A program with generics that is compiled with JDK 1.5 beta1 without the "-source 1.5" option behaves oddly: it compiles but sometimes fails to execute. It shouldn't behave like that. It should fail in the compilation, with a complaint about using the wrong version of the language.
    This odd behaviour doesn't always occur! In the small program below, I get that behaviour when using the EnumSet.range method.
    If I only use the basic EnumSet, it does executes.
    -- Lars
    import java.util.EnumSet;
    import java.util.*;
    public class Example {
         public enum Season { WINTER, SPRING, SUMMER, FALL }
         public static EnumSet<Season> warmSeason = EnumSet.range(Season.SPRING, Season.FALL);
         public static void main(String[] args) {
              System.out.println("Season: ");     
              for (Season s : Season.values()) {
              System.out.println(s);
              System.out.println("Cold Season: ");     
              for (Season s : warmSeason) {
              System.out.println(s);

    Example.java:6: warning: as of release 1.5, 'enum' is a keyword, and may not be used as an identifier
        public enum Season { WINTER, SPRING, SUMMER, FALL }
               ^
    Example.java:6: ';' expected
        public enum Season { WINTER, SPRING, SUMMER, FALL }
                           ^
    Example.java:12: ';' expected
            for (Season s : Season.values()) {
                          ^
    Example.java:17: illegal start of expression
            for (Season s : warmSeason) {
            ^
    Example.java:20: ';' expected
        ^
    4 errors
    1 warning

  • Install problem JDeveloper 12c (12.1.2.0.0) (Build 6668) with Generic Installer on windows

    Hi,
    I am trying to install JDeveloper 12c (12.1.2.0.0) (Build 6668) with Generic Installer on windows .
    C:\Program Files\Java\jdk1.7.0_25\bin>java -jar C:\jdev_suite_121200.jar
    I get the following error :
    Extracting files................................................................
    Unsupported platform (unable to determine the startup directory location).
    The Oracle Universal Installer failed.  Exiting.
    When I try with windows install ( right click jdev_suite_121200_win32.exe and "run as administrator") , I get the following error:
    ERROR Launch:No such file or directory
    In the discussion (https://forums.oracle.com/thread/2573396?start=0&tstart=0) , it is said to be solved by "running as administrator" but it didn't work for me ...
    Thanks ...

    Hi,
      Can you please tell whether you are using 32-bit or 64-bit windows.
      If it is 64-bit then you must run as administrator. In Windows 7x64, just right click on the jDeveloper exe and choose "run as administrator..."
      Remove the existing Oracle folder and restart the system.
      Try to install in new drive.
      Oracle Fusion Middleware Installation Guide for Oracle JDeveloper - 11g Release 2 (11.1.2.4.0) Hope this link will give you more idea in installation.
    Thanks
    Pramila
    Message was edited by: d6866663-7e0d-4497-89df-99f670c41872

  • How to smoothly migrate from System PG to Generic PG?

    The customer has UCCE version 8.5. He uses System PG.
    There is a need to implement EIM / WIM, but according to the documentation:
    E-Mail Manager Option, Web Collaboration Option, as well as E-Mail Interaction Manager and Web Interaction Manager (Unified EIM/WIM) are not supported with deployments that use the System PG. (http://docwiki.cisco.com/wiki/Compatibility_Matrix_for_Unified_CCE)
    Does anyone have an idea of ​​how is better to migrate from the System PG to Generic PG? And how to save the existing statistics in HDS database?

    Hi,
    I am afraid it's not possible.
    You can try changing the type of the PG to Generic PG, but you'll have to create two PIM types (CallManager/SoftACD and VRU), and this would, of course, generate new Peripheral ID's, and a whole new way of database records, for instance, TCD's.
    G.

  • The System.arraycopy Functionality and copying array question

    When created arrays such as String[] myStringArray (for example), is it general good practice to use the System.arraycopy function to copy the array?
    Why isn't it good practice to use equal instead? Would this work just as well?
    String[] myStringArray = new String[] { "My", " Test"};
    String[] myStringArrayCopy = new String[myStringArray.length};
    myStringArrayCopy = myStringArrayCopy;Or is that just going to make them the same element in memory and if I change myStringArray in antoher part of the program that means myStringArrayCopy will change as well since it is the same thing?

    Youre right, the equals sign just assigns the new array same reference in memory as the old array so they are pointing to the same data.
    Im 90% sure of that.
    If you want to work with an array without changing the original array id suggest using the System.arraycopy method. If you dont mind the contents changing then use the = sign..(but then why use a new array at all?)
    Hope this helps, if not theres loads of more experienced people on the boards...
    Ocelot

  • Why System.arraycopy function does not follow java naming conventions ?

    System.arraycopy should be
    System.arrayCopy....
    can anyone tell me why is it so ?

    BigDaddyLoveHandles wrote:
    DogsAreBarking wrote:
    System.arraycopy should be
    System.arrayCopy....
    can anyone tell me why is it so ?Because it dates back to the early days of Java, back when rocks were soft. Note also that java.awt.GridBagLayout has several methods that start with capital letters! Shocking!Hmm, I never noticed that. And in version 1.4 they apparently added identical methods which names that start with lower case. Now that's a funky API :-)
    Along the same line, one thing that irks me is that eclipse keeps suggesting
    Color.blackas the first auto-completion choice when I type
    Color.BThe horror!

  • ArrayStoreException by System.arraycopy

    Hi!
    I've made a simple code, which uses System.arraycopy, but it constantly throws ArrayStoreException, even though I can't see any reason for this.
    (I've even run through it and watched the variables at breakpoints.) It seems as if it cannot convert Integer to Integer, but why?
              My code is here:
              import java.lang.reflect.Array;
    public class ArrayHandler {
         public static void main(String[] args) {
              try {
                   Integer[] startArray=new Integer[]{new Integer(1)};
                   Integer[] endArray=new Integer[]{new Integer(2)};
                   Object[] result=new ArrayHandler().appendArray(startArray, endArray);
              }catch(Throwable exception){
                   exception.printStackTrace();
    http://java.sun.com/j2se/1.3/docs/api/java/lang/System.html#arraycopy%28java.lang.Object,%20int,%20java.lang.Object,%20int,%20int%29
    Otherwise, if any of the following is true, an ArrayStoreException is thrown and the destination is not modified:
          * The src argument refers to an object that is not an array.
          * The dst argument refers to an object that is not an array.
          * The src argument and dst argument refer to arrays whose component types are different primitive types.
          * The src argument refers to an array with a primitive component type and the dst argument refers to an array with a reference component type.
          * The src argument refers to an array with a reference component type and the dst argument refers to an array with a primitive component type.
        Otherwise, if any actual component of the source array
        from position srcOffset through srcOffset+length-1
        cannot be converted to the component type of the destination array by assignment conversion,
        an ArrayStoreException is thrown.
        In this case, let k be the smallest nonnegative integer less than length
        such that src[srcOffset+k] cannot be converted to the component type of the destination array;
        when the exception is thrown,
        source array components from positions srcOffset through srcOffset+k-1
        will already have been copied to destination array positions dstOffset through dstOffset+k-1
        and no other positions of the destination array will have been modified.
        (Because of the restrictions already itemized,
        this paragraph effectively applies only to the situation
        where both arrays have component types that are reference types.)
         public Object[] appendArray(Object[] startArray,Object[] endArray) {
              Object[] outputArray=startArray;   
              Class startArrayClass=startArray.getClass();
              System.out.println(startArrayClass);
              Class endArrayClass=startArray.getClass();
              System.out.println(endArrayClass);
              if(startArrayClass !=endArrayClass){
                   //throw new Exception("startArrayClass !=endArrayClass");
              }else{
                   try{
                        outputArray=(Object[])Array.newInstance(startArrayClass, startArray.length+endArray.length);   
                        System.arraycopy(startArray,0,outputArray,0,startArray.length);
                        System.arraycopy(endArray,0,outputArray,startArray.length,endArray.length);
                        return outputArray;
                   }catch(Throwable exception){
                        exception.printStackTrace();
              return outputArray;
         }//appendArray
    }Could anybody share his experience, please.
    My best regards.

    astlanda wrote:(I've even run through it and watched the variables at breakpoints.)Thank's for your time.
    I'm using Eclipse and I know a bit how to debug with it.
    Everything was as expected, but I can't see into a native method like
         * Copies an array from the specified source array, beginning at the
         * specified position, to the specified position of the destination array.
         * A subsequence of array components are copied from the source
         * array referenced by <code>src</code> to the destination array
         * referenced by <code>dest</code>. The number of components copied is
         * equal to the <code>length</code> argument. The components at
         * positions <code>srcPos</code> through
         * <code>srcPos+length-1</code> in the source array are copied into
         * positions <code>destPos</code> through
         * <code>destPos+length-1</code>, respectively, of the destination
         * array.
         * <p>
         * If the <code>src</code> and <code>dest</code> arguments refer to the
         * same array object, then the copying is performed as if the
         * components at positions <code>srcPos</code> through
         * <code>srcPos+length-1</code> were first copied to a temporary
         * array with <code>length</code> components and then the contents of
         * the temporary array were copied into positions
         * <code>destPos</code> through <code>destPos+length-1</code> of the
         * destination array.
         * <p>
         * If <code>dest</code> is <code>null</code>, then a
         * <code>NullPointerException</code> is thrown.
         * <p>
         * If <code>src</code> is <code>null</code>, then a
         * <code>NullPointerException</code> is thrown and the destination
         * array is not modified.
         * <p>
         * Otherwise, if any of the following is true, an
         * <code>ArrayStoreException</code> is thrown and the destination is
         * not modified:
         * <ul>
         * <li>The <code>src</code> argument refers to an object that is not an
         *     array.
         * <li>The <code>dest</code> argument refers to an object that is not an
         *     array.
         * <li>The <code>src</code> argument and <code>dest</code> argument refer
         *     to arrays whose component types are different primitive types.
         * <li>The <code>src</code> argument refers to an array with a primitive
         *    component type and the <code>dest</code> argument refers to an array
         *     with a reference component type.
         * <li>The <code>src</code> argument refers to an array with a reference
         *    component type and the <code>dest</code> argument refers to an array
         *     with a primitive component type.
         * </ul>
         * <p>
         * Otherwise, if any of the following is true, an
         * <code>IndexOutOfBoundsException</code> is
         * thrown and the destination is not modified:
         * <ul>
         * <li>The <code>srcPos</code> argument is negative.
         * <li>The <code>destPos</code> argument is negative.
         * <li>The <code>length</code> argument is negative.
         * <li><code>srcPos+length</code> is greater than
         *     <code>src.length</code>, the length of the source array.
         * <li><code>destPos+length</code> is greater than
         *     <code>dest.length</code>, the length of the destination array.
         * </ul>
         * <p>
         * Otherwise, if any actual component of the source array from
         * position <code>srcPos</code> through
         * <code>srcPos+length-1</code> cannot be converted to the component
         * type of the destination array by assignment conversion, an
         * <code>ArrayStoreException</code> is thrown. In this case, let
         * <b><i>k</i></b> be the smallest nonnegative integer less than
         * length such that <code>src[srcPos+</code><i>k</i><code>]</code>
         * cannot be converted to the component type of the destination
         * array; when the exception is thrown, source array components from
         * positions <code>srcPos</code> through
         * <code>srcPos+</code><i>k</i><code>-1</code>
         * will already have been copied to destination array positions
         * <code>destPos</code> through
         * <code>destPos+</code><i>k</I><code>-1</code> and no other
         * positions of the destination array will have been modified.
         * (Because of the restrictions already itemized, this
         * paragraph effectively applies only to the situation where both
         * arrays have component types that are reference types.)
         * @param      src      the source array.
         * @param      srcPos   starting position in the source array.
         * @param      dest     the destination array.
         * @param      destPos  starting position in the destination data.
         * @param      length   the number of array elements to be copied.
         * @exception  IndexOutOfBoundsException  if copying would cause
         *               access of data outside array bounds.
         * @exception  ArrayStoreException  if an element in the <code>src</code>
         *               array could not be stored into the <code>dest</code> array
         *               because of a type mismatch.
         * @exception  NullPointerException if either <code>src</code> or
         *               <code>dest</code> is <code>null</code>.
        public static native void arraycopy(Object src,  int  srcPos,
                                            Object dest, int destPos,
                                            int length);

  • Using System.arraycopy to copy an array into itself.

    I was wondering if there are any potential problems with using code similar to below?
    System.arraycopy(Global.queueUrgent, 1, Global.queueUrgent, 0, Global.queueUrgent.length-1); I have an array which works as a job queue. Another thread looks at this queue and then acts on it according to the data held in Global.queueUrgent[0]. Once this task has been accomplished, the first job is removed and the rest of the queue is brought forward one (and hence the code sample).
    I understand the risks of a race condition which might occur in my application and can prevent it as much as possible but I was wondering if there were any other concerns I should address. It's important that I use an array such as this for my project.
    I haven't tried to implement the code as of yet as I would like to hear your thoughts on it first.
    Regards,
    Robert (1BillionHex).

    user13702320 wrote:
    "If the src and dest arguments refer to the same array object, then the copying is performed as if the components at positions srcPos through srcPos+length-1 were first copied to a temporary array with length components and then the contents of the temporary array were copied into positions destPos through destPos+length-1 of the destination array. "
    Yeah I understand that. I was just wondering if there was anything that I was missing.
    It says "as if" it is copied to a temporary array. Does it actually do this? If so and if I use a large array, would this have an impact on memory usage?It doesn't matter if it actually does it using a temporary array. The point is, it is safe to use the same array for src and dest. Note that java.util.ArrayList's 'remove' method uses exactly the code that you are using. I don't know about memory usage effects. If you do this manually, you do need to set Global.queueUrgent[Global.queueUrgent.length-1] to null to ensure that the objects will be able to be garbage-collected properly when it is time (see what ArrayList.remove does). If you don't, then if you had a 5-element array and remove all 5 elements, you will end up with 5 references to what was originally only in queueUrgent[4], and the object won't be eligible for garbage-collection.
    I did have the same question as Kayaman--why not use a real queue? There are several built-in classes that you can use, instead of using an array directly. You claimed that "It's important that I use an array such as this for my project.", but you didn't explain why you think you must use an array.

  • System.arraycopy timing

    I ran the following test to determine the relative efficiency of moving int and byte array members. It was run on a Windows XP Pro machine @ 2GHz.
    The duke is for the first person that correctly predicts the output. Actually running the code is definitely cheating.
    In an early version I had more complexity just to be sure the compilers didn't notice that the code was only overwriting some zeros with other zeros. They weren't that smart. A million array elements actually get shifted here.
    public class test {
        static final int K = 1024;
        static int tsize = K * K;
        static int[] ints = new int[ tsize ];
        static byte[] bytes = new byte[ tsize ];
        public static void main( String[] args ) {
            long start, stop;
            start = System.currentTimeMillis();
            System.arraycopy( ints, 0, ints, 1, tsize-1 );
            stop = System.currentTimeMillis();
            System.out.println("ints: " + (stop-start) );
            start = System.currentTimeMillis();
            System.arraycopy( bytes, 0, bytes, 1, tsize-1 );
            stop = System.currentTimeMillis();
            System.out.println("bytes: " + (stop-start) );
            System.exit( 0 );
        } // end of main()
    } // end of test

    I ran the following test to determine the relative
    efficiency of moving int and byte array members. It
    was run on a Windows XP Pro machine @ 2GHz.
    The duke is for the first person that correctly
    predicts the output. Actually running the code is
    definitely cheating.Well, I cheated. Does that make me a bad person? Anyway, my guess was that whichever test run first would be slightly slower, no matter if it was bytes or ints. I was wrong.
    >
    In an early version I had more complexity just to be
    sure the compilers didn't notice that the code was
    only overwriting some zeros with other zeros. They
    weren't that smart. A million array elements actually
    get shifted here.
    public class test {
    static final int K = 1024;
    static int tsize = K * K;
    static int[] ints = new int[ tsize ];
    static byte[] bytes = new byte[ tsize ];
    public static void main( String[] args ) {
    long start, stop;
    start = System.currentTimeMillis();
    System.arraycopy( ints, 0, ints, 1, tsize-1
    tsize-1 );
    stop = System.currentTimeMillis();
    System.out.println("ints: " + (stop-start) );
    start = System.currentTimeMillis();
    System.arraycopy( bytes, 0, bytes, 1, tsize-1
    tsize-1 );
    stop = System.currentTimeMillis();
    System.out.println("bytes: " + (stop-start)
    -start) );
    System.exit( 0 );
    } // end of main()
    } // end of test

  • System.arraycopy()

    I have an array of 1000 ints:
    int[] a = new int[1000];After I fill it with random integer values, I want to sort it with one method iteratively and one method recursively.
    It was suggested to me to use System.arraycopy(src, srcPos, dest, destPos, length) to make a copy of the array and then pass it to the two different methods.
    How can I go about doin this....

    Here's a demo:
            int[] array = {5,3,1,2,4};
            int[] copy = new int[array.length];
            System.arraycopy(array, 0, copy, 0, copy.length);
            System.out.println("array -> "+java.util.Arrays.toString(array));
            System.out.println("copy  -> "+java.util.Arrays.toString(copy));

Maybe you are looking for

  • Report- material document for allocation- adding transfers

    Hi! Can anyone help me in cretainmg this small report to use for adding transfers to allocation table please? Its a small report but somehow I am not reaching the target --new block Selection Screen: Material Document of Original Transfer Posting (10

  • How to use view objects in entity impls?

    Hi! I would like to access a view object to implement business logic in an entity impl class method. How can this be done? More precisely I would of course like to do this in the context of the "current" Application Module the Entity "lives" in. I th

  • Advanced question for running DOS programs on a Mac.

    So what is a simple process on a Windows machine seems to be a challege on my new Mac. In summary I have several hard drives laying around that need to be checked for problems before they are used. There are lots of free DOS programs available for PC

  • Runtime error after successful compile and link with cl.exe

    Finally, got the configuration for cl.exe and link.exe right and got a successful compile and link to produce a dll. Then ran the main method of my Java class. The main method calls the constructor, and loading the class runs the static block which l

  • Seeing double images, wanna see just one?

    I am seeing two sets of images. One is the master/original the other is an altered version of it. What do I do to just display the latest/altered version?