LinkedList toArray() doesnt work well

toArray() doesnt work as expected
any suggestion?
thx~
>
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.Integer;
     at util.ArrayUtil.main(ArrayUtil.java:22)
{quote}
package util;
import java.util.*;
public class ArrayUtil
{   public static <E> E[] merge(E[]... e)
    {     LinkedList<E> ll = new LinkedList();
     for(E[] e_temp : e)
     {   if(e_temp == null) continue;
         for(E e_temp2 : e_temp) if(e_temp2 != null) ll.add(e_temp2);
     return (E[])ll.toArray();
    public static void main(String[] args)
    {     Integer[] a1 = null;
     Integer[] a2 = null;
     Integer[] a3 = {1,2,3};
     Integer[] a4 = {4,5,6};
     Integer[] a = (Integer[])merge(a1, a2);                //ClassCastException is triggered
     System.out.println(a.length);
     for(int i=0; i<a.length; i++)
     System.out.println(a);

could you pls show me a sample?
public static <E> E[] merge(E[]... e)
    {     LinkedList<E> ll = new LinkedList<E>();
     for(E[] e_temp : e)
     {   if(e_temp == null) continue;
         for(E e_temp2 : e_temp) if(e_temp2 != null) ll.add(e_temp2);
     E[] out = (E[])Array.newInstance(e.getClass(), ll.size());
     return ll.toArray(out);
    }Exception in thread "main" java.lang.ClassCastException: [[[Ljava.lang.Integer; cannot be cast to [Ljava.lang.Integer;
     at util.ArrayUtil.main(ArrayUtil.java:23)
{quote}

Similar Messages

  • Google maps has gone away from ios6 and apple maps doesnt work well for India. Stuck ??

    Apple released there own maps, and got away with google maps....Now, For lots of countries like India etc , apple maps arent done well yet... and google had a wonderful support all across lots of countries. Getting away from google maps has made us stuck with maps functional on iphone4 and ios6.
    This is not working well updating ios6 and we are losing biggest use of iphone (Maps)

    3 Good Alternatives for India
    Google maps web app(maps.google.co.in) 
    Nokia maps web app(m.maps.nokia.com) 
    Navfree GPS Live India https://itunes.apple.com/in/app/navfree-gps-live-india/id434595644?mt=8
    You can refer the below url for more information
    http://ebloggergeneric.blogspot.in/2012/09/alternatives-to-ios6-maps.html

  • How do I clean my macbook pro after spilling coffee on it and it doesnt work well now

    Anyone spilt coffee over their macbook ?Mine won't work properly now.....on go slow and keys not working?Help?

    Turn off your computer.  Using it after liquid damage can further damage its components.
    Get your computer into a bin of rice.  Rice is great at absorbing moisture.
    Contact your closest Apple Authorized Service Provider to see if they can help repair accidental damage.  Apple Retail Stores generally don't repair accidental damage.

  • Button in Adobe Flash CS6 doesnt work well

    after exported my fla, i was trying to check how the button works through the SWF, and everytime click the button, the swf always quit, ive checked all the AS and also the button itself and nothing wrong with the AS or the button. whats wrong??? >< i need ur help

    after exported my fla, i was trying to check how the button works through the SWF, and everytime click the button, the swf always quit, ive checked all the AS and also the button itself and nothing wrong with the AS or the button. whats wrong??? >< i need ur help

  • Why Safari  doesnt work well as well google chrome?

    I am using Macbook pro intel 2.4 ghz, 8 gb ram and os x 10.8.3 downloaded. I always want to use safari because of icloud and for other apple apps on this but i cannot react my impulse as well as google chrome or firefox? how can i change this issue?

    serbura wrote:
    how can i change this issue?
    You can't, other than using another browser.
    Why Apple has slipped to last place in the browser wars is beyond me, maybe because in the future it's not going to matter, you use Safari and can use nothing else perhaps.
    My Firefox is the fastest with the broadband tweaks, loads a page in one second where Safari takes 1.5-3 seconds or more sometimes for some reason.
    For Snow Leopard Speed Freaks

  • WRT54GS doesnt work well with vista

    hey i have the wrt54gs wireless router and i have a new hp laptop with an internal wireless g card and when i connect to the router i only get a 60% on the wireless connection and im right next to the router.... lol when i used to have windows media center on this laptop i would get 100% is there some kind of firmware update or sumthin for this router so it could work better or do i have to install the program that linksys comes with

    yes u can always go for the firmware update...check out the hardware version of WRT54GS on the unit itself...then go to www.linksys.com/download and get the firmware file for the router model no......
    now, connect the laptop to one of the LAN ports of the router..access the router using http://192.168.1.1 . Keep the username blank and password is "admin"..this is the default password...however, if u changed the password during the installation, that password needs to be entered.
    once on the web interface, go to the "administration" tab and click on "firmware upgrade" subtab and browse the firmware file and click "upgrade"......after upgrading the firmware , reset and reconfigure the router....

  • Test Plan Doesnt Work Well

    Hi,
    How do I make the "Test plans"  (stcode = stwb_1 or stwb_2)  run the scripts taking into account the values of the "Test Data" (stcode =secatt). This only occurs when run straight from the "Test Configuration" (stcode =secatt).
    Regards.
    Diovani.

    The only way I know to use the test data container with a test script is to combine them in a test configuration. In STWB_1 Test Catalog Management the test configuration can be added to a test catalog:
    Select the test catalog
    Change mode
    One of the two insert buttons u201CAs Subnodeu201D or u201COn Same Levelu201D
    In the pop-up choose radio button u201CTest Caseu201D and for Type select u201CeCATT Test Configurationu201D
    Choose the test configuration you created in SECATT earlier.
    Select one of the u201CVariant Selectionu201D radio buttons, e.g. u201CAll Variants excl. Default Variantu201D.
    Run the test case
    When I do this it runs the script for each record in the test data container. Good luck,
    David

  • Deauthorizing itunes account on old pc that doesnt work well?

    i have 2 computers that is authorized by my itunes account and i would like to remove 1 from my pc that needs to be sent in for a video card repair, i told my mom i was going to deauthorize my itunes account on my tower pc but she told me not to and said doing that would delete my itunes account, but it won't right? just making sure i understand thanks if anyone can help me!

    Deauthorizing deletes nothing.
    Authorization only give permission to listen to DRM (pre-itunes plus) music.  It does not affect what is stored on your computer or in your itunes library at all.

  • Oracleasm-support-2.1.5-1.el6.x86_64 doesnt work on OL 6.0 UEK

    ASMlib keeps return "Instantiating disk: failed" while trying to create ASM disks. It happens on both Clariion and Symmetrix devices.
    [root@sgelxha198 ~]# uname -a
    Linux sgelxha198 2.6.32-100.28.5.el6.x86_64 #1 SMP Wed Feb 2 18:40:23 EST 2011
    x86_64 x86_64 x86_64 GNU/Linux
    [root@sgelxha198 ~]# cat /etc/redhat-release
    Red Hat Enterprise Linux Server release 6.0 (Santiago)
    [root@sgelxha198 ~]# rpm -aq |grep oracleasm
    oracleasm-support-2.1.5-1.el6.x86_64
    [root@sgelxha198 ~]# syminq |grep mpath
    /dev/mapper/mpatha DGC RAID 5 0531 160018CC 5242880
    /dev/mapper/mpathb DGC RAID 3 0531 170018CD 5242880
    /dev/mapper/mpathc DGC RAID 1 0531 180018CE 5242880
    /dev/mapper/mpathd DGC RAID 10 0531 190018CF 5242880
    /dev/mapper/mpathe DGC VRAID 0531 1A4CE9B7 104857600
    /dev/mapper/mpathf DGC VRAID 0531 1B4CE9B7 104857600
    /dev/mapper/mpathah EMC SYMMETRIX 5875 1600050000 N/A
    /dev/mapper/mpathai EMC SYMMETRIX 5875 1600E44000 5280000
    /dev/mapper/mpathaj EMC SYMMETRIX 5875 1600E45000 5280000
    /dev/mapper/mpathak EMC SYMMETRIX 5875 1600E46000 5280000
    /dev/mapper/mpathal EMC SYMMETRIX 5875 1600E47000 5280000
    /dev/mapper/mpatham EMC SYMMETRIX 5875 1600E48000 5280000
    [root@sgelxha198 ~]# ls -l /dev/mapper/*p1
    lrwxrwxrwx. 1 root root 8 Feb 9 03:13
    /dev/mapper/360060160f6102900507cc7b2c3f5df11p1 -> ../dm-16
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathahp1 -> ../dm-18
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathaip1 -> ../dm-23
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathajp1 -> ../dm-24
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathakp1 -> ../dm-25
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathalp1 -> ../dm-26
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathamp1 -> ../dm-27
    lrwxrwxrwx. 1 root root 7 Feb 9 03:30 /dev/mapper/mpathap1 -> ../dm-8
    lrwxrwxrwx. 1 root root 7 Feb 9 03:30 /dev/mapper/mpathbp1 -> ../dm-9
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathcp1 -> ../dm-10
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathdp1 -> ../dm-12
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathep1 -> ../dm-11
    lrwxrwxrwx. 1 root root 8 Feb 9 03:30 /dev/mapper/mpathfp1 -> ../dm-13
    [root@sgelxha198 log]# oracleasm status
    Checking if ASM is loaded: yes
    Checking if /dev/oracleasm is mounted: yes
    [root@sgelxha198 log]#
    [root@sgelxha198 ~]# oracleasm createdisk cxdisk /dev/mapper/mpathap1
    Writing disk header: done
    Instantiating disk: failed
    Clearing disk header: done
    [root@sgelxha198 ~]# oracleasm createdisk vmaxdisk /dev/mapper/mpathaip1
    Writing disk header: done
    Instantiating disk: failed
    Clearing disk header: done
    mpatha (360060160f6102900505745e1c3f5df11) dm-3 DGC,RAID 5
    size=5.0G features='0' hwhandler='1 alua' wp=rw
    |-+- policy='round-robin 0' prio=50 status=active
    | `- 3:0:0:1 sdj 8:144 active ready running
    `-+- policy='round-robin 0' prio=10 status=enabled
    `- 2:0:0:1 sdb 8:16 active ready running
    [root@sgelxha198 ~]# multipath -ll mpathai
    mpathai (360000970000192602316533030453434) dm-17 EMC,SYMMETRIX
    size=5.0G features='0' hwhandler='0' wp=rw
    `-+- policy='round-robin 0' prio=1 status=active
    |- 2:0:1:1 sdr 65:16 active ready running
    `- 3:0:1:1 sdq 65:0 active ready running

    According to http://www.oracle.com/technetwork/topics/linux/asmlib/index-101839.html No ASMLIB driver package needs to be installed when using this kernel. Moreover doing a search on ASM related rpm in ULN, I can only get what's shown here:
    [root@sgelxha198 ~]# yum search oracleasm
    Loaded plugins: refresh-packagekit, rhnplugin
    ======================================================== Matched: oracleasm ========================================================
    oracleasm-support.x86_64 : The Oracle Automatic Storage Management support programs.
    I even uninstalled oracleasm-support-2.1.5-1.el6.x86_64 and reinstalled with earlier version (oracleasmlib-2.0.4-1.el5.x86_64.rpm & oracleasm-support-2.1.3-1.el5.x86_64.rpm), but I still get the same result.
    I suspect that the integrated ASMLIB driver doesnt work well.

  • HT1689 my ipad 2 doesnt work that well. it always hang by it self after i updated the latest ios 7.

    my ipad 2 doesnt work that well. it always hang by it self after i updated the latest ios 7.

    you should backup and restore via itunes

  • My iPod mic doesnt work very well even when its by my mouth why is that?

    My ipod mic when i facetime doesnt work very well the other person cant hear me sometimes why is that?

    The mic is the little hole on the back side of the iPod by the camera lens. It is clear and unobstructed?
    Open the Voice Memos app and see if you get good respnse on the VU meter.

  • Ive up grade the firefox and now is very slowly, it doesnt work very well. How can i download ther older one?

    ive upgrade the firefox and now doesnt work very good. how can i use the older one version? Thanks

    Firefox doesn't work very well in what sense ?? Can you explain a bit more about the problems you are facing in using Firefox ??
    Might not be related to your problem but some of your Plugins are out-dated
    * Update All your Firefox Plugins -> [https://www.mozilla.org/en-US/plugincheck/]
    * '''When Downloading Plugins Update setup files, Remove Checkmark from Downloading other Optional Softwares with your Plugins (e.g. Toolbars, McAfee, Google Chrome, etc.)'''

  • My iphone works well...then suddenly hang and turn off...trying to turn on, doesnt work trying the power and home button at the same time for many time doesnt work either. try to charged but not charging...trying to access in itunes, cannot access...

    my iPhone works well...suddenly hang when im on the phone...trying to reset with the home and power button, doesnt work, trying to charge for for several hour..its not charging, trying to access in itunes,,cannot acces.....what to do...please help

    Has it ever gotten wet?..   I'd make an appointment with Genius bar at an Apple store, there's something majorly wrong that a simple 'reset' isn't going to fix...
    Sorry...

  • Alternative for HP simple pass (which doesnt work very well at all)

    SO, after using HP simple pass on IE only bcause it doesnt work on CHROME...i upgraded to the latest HP simplepass....still doesnt work on chrome and now it functions very porly on IE too....it fails to ask to save/load passowords and if it does ask for a new site, if you enter the wrong PW, it saves it and doesnt ask to save a new second username like in the old version...SO I HAVE GIVEN UP ON SIMPLE PASS>...
    are there any good (paid or free) alternatives????
    thanks

    Hey @envy15touchscre ,
    Welcome to the HP forums.
    I understand you're unhappy with the new version of HP SimplePass.
    You should be able to restore the original version of SimplePass by using the HP Recovery Manager: Using Recovery Manager to Restore Software and Drivers (Windows 8).
    I have not personally tried any other security plugins for browsers to make a suggestion.
    Thanks.
    Please click the "Kudos, Thumbs Up" at the bottom of this post if you want to say "Thanks" for helping!
    Please click "Accept as Solution" if you feel my post solved your issue, it will help others find the solution.
    The Great Deku Tree
    I work on behalf of HP.

  • Click wheel doesnt work so well

    I have had my i-pod mini for a year and a half and had no problems until now. Recently i went to use my i-pod and everything works except for when i press the menu button on the click wheel. I have tried to reset the i-pod but that doesnt work because the menu button doesnt respond. If anyone has any advice it would be greatly appreciated.
    Thanks
    -Joel

    HI Atomicskier,
    Welcome to Apple Discussions
    Have you tried Restoring it? You might want to look at Knowledge Base Document #60983, which has instructions on Restoring iPod to Factory Settings.
    Jon

Maybe you are looking for

  • Has anyone been getting a different video than the one you are clicking in youtube on ipad?

    Hello I've been experiencing weird stuff in youtube app in my ipad. whatever video I click, I get this same video of an indian song clip! i tried restarting, deleting history, signing out of my youtube account. pls help me :'(

  • Web template not capturing in Transport

    Hi experts, I am Saving as an existing web template and inserting my query in the new template. When I try to transport that Web Report, the new web template is not getting captured. What can be the problem?

  • Adobe Reader XI use 100 % of the processor in Internet Explorer

    We have sequenced Adobe Reader XI with App-V 5.0 SP2 hotfix 5. This package is deployed in our Windows 2008 R2 Citrix XenApp 7.6 server. When we open a PDF document in Internet Explorer, after about 10 seconds IE freeze and this process use 100% of o

  • Single-plot cursor tree -- how to programmatically collapse it?

    How do you programmatically collapse a single-plot cursor tree? I am saving and restoring waveforms to a waveform graph. Sometimes loading the waveform causes the cursor tree to display collapsed (Example 1), which is desired so the coordinates for b

  • Please help...syncing?  Streaming?

    Hi Gang, My ATV is acting kinda weird after the 2.0 update. Everything was fine with the original firmware. Here is my situation: I only have an Airport Snow. Because it takes so long to sync movies, etc., I was hooking the ATV to my laptop via Ether