2 Replies Latest reply: Oct 22, 2007 4:53 AM by 807603 RSS

    Converting int[] to Integer[]

      How to convert an int array to Integer[] without iterating the int[]?

      we can traverse the int[] and add to Integer[]. But the traversing takes too much time. Is there any method to do the above conversion?
        • 1. Re: Converting int[] to Integer[]
          If you are using 1.5, you can use the individual elements of the int[] as if they were an Integer, so why do you need to convert it? If it is to pass the array as an argument, then sorry, you are going to have to traverse the arrays and set the elements. And, at most, this will take a second or two of time (even if you have an array of nearly max size), so in what way is this "taking too much time"?

          Edit: And any API method to do this with a single line of code, would still, inside the method, need to traverse the arrays, so now time would be saved. If it is to save programming time, then take a few minutes to write a method for it now, and then every time you need it in the future, just use that method.
          • 2. Re: Converting int[] to Integer[]
            Who says it takes too much time? Have you actually measured it, or just assuming it? Traversing the array one at a time is the only way. Or, you could not bother, and only make the change to Integer when you actually finally need an Integer