Combining two ArrayLists of Integers into a new ArrayList.

Basicly I have two arrayLists that have a list of numbers and I want to add them both into one new arrayList in the same index. Example
aList1 = [ 4 , 5 , 10 , 33 ]
aList2 = [ 1 , 3 , 19 ]
combinedList = aList1 + aList2
print out combinedList = [4,5,10,33,1,3,9]
That's what I want out of it but the only way I can do this is if I write
combinedList.add[aList1]
combinedList.add[aList2]
but it would come out like [ 4 , 5 , 10 , 33 ] [ 1 , 3 , 19 ]. Two seperate indexs holding a list of Integers. Where I need it to be [4 , 5 , 10 , 33 , 1 , 3 , 9]
Which is incorrect cause they are in seperate indexs. I need to place both of them into the same index starting with all the numbers for aList1 and then aList2.
I could just go through each aList1 index and placed each one into a new arrayList and then do that with aList2 but I'm trying to make this a little more efficient than that. I tried using addAll but it seems to add each arrayLists as an object and that just comes out like 2. Here's some of the code from by program.
Collections.sort(alist1);
Collections.sort(alist2);
aNewList.add(alist1);
aNewList.add(alist2);   
return aNewList;Like I said I could do it the long way but I'm trying to keep the complexity to a minimum. Any help would be very much appreciated. Thanks :)
Edited by: DavidMilot on Oct 18, 2008 6:08 PM

DavidMilot wrote:
Not to be rude I just cannot copy and paste all my code into the forum out of fear of plagerism.I didn't mean for you to post all of your code. Just a small program that demonstrates the problem. This program would have 3 arraylists on it, 2 filled, one empty that would receive the other two. You combine them, print out the third and that's it.
I could rename all my variables and method names but I unfortunately don't have time to do all that because I have 3 midterms coming in 3-4 days. This doesn't seem to be an easy fix just by giving out minimal code (which the names have been altered) but I still appreciate the effort. For now I tend to leave the code the way it is havingThe onus of effort here must be yours.
newList.add(aList1)
newList.add(aList2)
It's not perfect but that's as close as I can get for now. Plus this assignment is due monday hehe. Feel free to continue giving me ideas to try out I plan to ask my TA monday before handing it in. Thanks again.I mainly wanted to see is if you are using addAll two add both aList1 and aList2. For some unknown reason in the code you posted before you didn't. Again, lord knows why.

Similar Messages

  • How do I combine two or more pictures into one?

    How do I combine two or more pictures into one?

    I found out how to do what I wanted and I'm giving my steps in hopes that it might help someone else.  I wanted to put several photos from a file onto a new blank image.  This is what I did.
    1.  Create a blank page.    File/New/ Blank File.   Put in the size.  I used 8x10.
    2.  Bring the photo  you want to use into Elements as you always do. It will list along the top next to the blank sheet.
    3.  Choose SELECT (top of screen)/ Select All.
    4.  Choose Edit/Copy   or Command "C"
    5.  Click on the Blank File.   Chose Edit/Paste  or Command "V"
    6.  Click on Image/ Transform or Command "T".  There should be a dotted line around your pasted image.  You can then move and adjust the image to how you want it.  When finished, press the check-mark on lower right of photo.
    7.   Repeat this with all the photos you want on the new blank file.
    8.  You will see on lower right of Elements,  the background layer and as many layers as you have photos.  These layers need to be permanently placed on the background layer. Go to Layers and press Merge Visible.  This will merge all layers to the background.
    9.  Save as and you are done.

  • Combining two StringBuffer array elements into a single array element

    I just need to know how to combine two stringBuffer array elements into one
    StringBuffer ciphertext [] = new StringBuffer[2];
              StringBuffer s0 = new StringBuffer("11011111111110001001101110110101");
              StringBuffer s1 = new StringBuffer("00010011001101000101011101111001");
              ciphertext[0] = s0;
              ciphertext[1] = s1;
              ciphertext[2] = ciphertext[0].append(ciphertext[1]);I get an array index out of bounds exception:2
    Thanks

    StringBuffer ciphertext [] = new StringBuffer[3];  // legal index values are: 0,1,2

  • How do I combine two one page documents into one two page document?

    How do I combine two one page documents into on two page document?????

    Menu > View > Show Thumbnails > Click on the thumbnail > Copy > Paste into the Thumbnails of the 2nd document
    Peter

  • How do I combine two user iPhoto files into one...keeps blocking the pics between users

    How do I combine two user iPhoto files into one...keeps blocking the pics between users on the same Mac?

    Put the library on an external hard drive that is formatted as shown in this screenshot:
    OT

  • Combining two like cd's into one in my library

    how do i combine two like cd's into one

    Give each CD its own disc number as Disc X of Y where in this case X would be 1 or 2, and Y would be 2. Then give both discs a common Album name and a common Album Artist.
    Personally I prefer to use sequential track numbers across both discs as well. For example if disc 1 has tracks 1-12 and disc 2 has tracks 1-13 I would renumber the tracks on the second disc as 13-25 and set a track total of 25 for all tracks on both discs.
    For more details see Grouping tracks into albums.
    tt2

  • Can I transfer Time Machine data from two separate hard drives into one new one?

    I'm using a MacBook Pro as my primary computer.  My 500 gig Time Capsule filled up a year or so ago, so I stopped using it with Time Machine for awhile so I could keep the data from those old back-ups.  There were a number of things I deleted from my computer's very limited hard drive after they were backed up to the Time Capsule.  I got a 1T external USB drive last year to use as my "filing Cabinet" to store files I didn't necessarily need all the time or that were filling up my small laptop hard drive--including my iTunes library--all organized in a way that made it relatively easy for me to find what I needed, even if I didn't remember exactly when I'd filed it or what I'd called it.  I got another 1 terabyte external (portable) drive last July and dedicated it to TimeMachine backups and labeled it "TimeMachine".
    Over the last couple of weeks, my friend has been helping me upgrade to Yosemite and clean up my laptop hard drive.  Last week he cloned my laptop hard drive to a new 1T hard drive and I exchanged it for my old drive in my computer today. All good.
    Here's the issue.  We replaced my Time Capsule hard drive with a 1 terabyte drive with the idea of transferring the data from the old Time Capsule (500G) drive and the newer USB 1T "TimeMachine" compact drive to the new 1T Time Capsule drive and beginning using the latter for my Time Machine backups going forward.  Originally he thought we could copy everything from each of my external drives (the old 500gig drive from my Time Capsule, the USB "TimeMachine" drive I've been using since July, and the "file cabinet" files) to my computer in their own folders and then start regular TimeMachine backups to the new Time Capsule drive, thus preserving all my old data and making regular backups going forward.  The "file cabinet" data was no problem at all, but when I tried to copy my USB "TimeMachine" data to my computer, I was unable to.  My friend found instructions for transferring old TimeMachine data to a new TimeCapsule, but I don't know if I can transfer the data from two separate disks to the new TimeCapsule drive. I'm afraid that one set of data will supersede the other and either my newer backups or my old ones will be lost if I try to transfer both. 
    Are my fears justified or is there a way to insure that no such problem will occur?  Of course, my data will still be on those two older drives, but that won't do me a lot of good if I can't access it when I need to. Also, the 1T drive now belongs to my friend; he used a brand new drive he'd bought for himself for my new internal hard drive and plans to take my 1T "TimeCapsule" drive in exchange, once the data has been transferred, so he will, of course, erase that drive. 

    Should we be able to bring up the old (500G) Time Capsule Drive to rename it using a SATA to FireWire harness and then copy the whole thing to the new Time Capsule drive?
    You can copy a whole sparsebundle from one drive to another. That is not a problem. Whether you can access the sparsebundle is something you should test before you even start though.
    If it's on the Desktop and I don't tell Time Machine to exclude it from backups, will it just automatically back it up?
    All drives you plug into the Mac are excluded by default.. you must include them. So no problems there.. but I hope I am understanding the question.
    Will both volumes or directories (which is the right term?) show up when I open Time Machine?
    No, Time Machine will only open what it is told to open... or its backup default location.
    You can force Time Machine to open alternative/old/no longer used backups by (now I have a problem as things have changed somewhat in Yosemite and I consider it alpha release software at this point in time). The old method was to right click on the TM icon and select a different TM backup. easy. Yosemite seems to have made easy stuff harder.
    Here it is on my current computer.. clearly not Yosemite.. Right click on the TM icon in the dock.. select Browse Other Time Machine Disks.. And supply the info of where that is located. Easy. If you cannot figure it out one of the other posters here (with more patience than me for Yosemite) will help you.
    Or will we have to partition the new drive somehow--is that even possible?
    I am getting more lost as I go down the list.. but the TC disk cannot be partitioned.
    If you have included all those USB drives in the new backup on a Time a Time Capsule.. you have made life rather hard because now your files are stored another layer deeper than they were.
    So to open a file from a disk you need to open the sparsebundle.. then dig down to the drive in question and then dig down to the backup.. and all of this means Time Machine has to work perfectly which is Yosemite is a very big ask.
    I thought you wanted to just backup your old drives to central location.. which means copying the files to a separate folder on the Time Capsule.
    One correction I need to make to my post, which will make my strategy make a bit more sense: my new Time Capsule drive is 4T
    It makes it much harder.. and I have to pose a real question of long term .. if you have put a 4TB drive in a Gen1 TC.. did you also replace its power supply because I can assure you the drive might be ok but the TC itself will not last forever.. and what happens when it dies. The Gen1 power supply is already well beyond its normal life span and the vast majority are dead. When the backup device is unreliable and the backups on it are made that much harder to get access to.. is this a great plan??
    If you are going to consolidate all your old files on one disk.. a task I find understandable. I have done much the same albeit the usefulness of files made on emac running OS9 may be questioned. A disk lying in the bottom of a draw is a more appropriate place for them.
    You want those files as easily accessible as possible (at the point of recovery) and not buried inside a sparsebundle.. particularly not a sparsebundle from the old TC disk buried inside a new sparsebundle.. keep files as accessible as possible as you can run searches.. and that is best done on a USB 3 (or faster ie thunderbolt) drive plugged into a new(ish) computer.. not network. And since the files are not being accessed on a daily/weekly or even monthly or yearly basis.. keeping them in actively running TC network storage.. I would say is a waste of space. That is only my opinion of course.. you might consider it highly important that files you will never look at are available any time of day or night when the urge comes to track down that elusive pimpernel email you sent 10 years ago... but I find it hard to justify. What the case.. the problem with TM and things like Mail is you cannot search it.. you must restore the whole library/files/program even before you can access it.. that makes file recovery out of a sparsebundle double step process.
    So.. summary.
    If you want to store files on the 4TB drive in the TC.. that is not a great strategy but it can work.. simply create a folder named.. OldFilesEMac for instance.. and do a simple copy and paste of all the file to that location. Do not use TM.. Since you have already used TM.. and from what I am reading you have already done the backup with the external drives included.. then you are going to end up needing to erase the TC and start over.. which you may not be prepared to do.. which is fair enough. (I am coming across as overbearing school master.. apologies).
    TM is to backup your main OS and current files.. not files from 10-20years ago.
    Please do read the issues involved in Pondini..
    See his FAQ. I recommend you read through Q14-17 so you understand what is involved in recovery.
    http://pondini.org/TM/FAQ.html
    I also recommend you read the first couple of articles here. http://pondini.org/TM/Home.html
    Particularly so you understand the complexity of Time Machine.
    And the articles here. http://pondini.org/TM/Time_Capsule.html
    Particularly Q3 on mixing data and backups on a TC.
    I wish I could spend an hour or two face to face and work it out.. the whole strategy to do this.. !!

  • Using Preview to combine pages from different documents into a new document

    I'm trying to create a single new pdf document by combining selected pages from several other pdf documents. However, when I drag pages from the older documents into the new one they retain the source file name. Then when I save the new document only the page that is active at the time of the save is actually saved.
    Is it possible to do what I'm trying to do? If so, what should I do that I'm not doing?
    Thanks,
    Eric Weir

    Thanks, Jeffrey. Sounded pretty straightforward. And it actually is -- once you get the hang of it. I had a couple attempts at "doing it" before I got it to work for me. At one point dragging a page to another location copied it instead of moving it. And at one point a page drug onto the new document somehow got identified there as a separate document that I knew was not going to get saved with the rest of the document.
    Either of these situations could have been salvaged if there was a way to delete a page from a document. I couldn't find one. Is there one?
    Anyway, I've got my document now. So thanks for your help.
    While I'm at it, I should say I never woulda found this solution on my own. There was no clue to it that I could find in the Preview help file. So double thanks.

  • Combining two different Chart types into one graph

    Hi All,
      I am developing a graphical BW report using WAD. I need to place two differnt chart types into one graph.For example, I have Volume and Quantity .Here the volume should be displayed in Bars and Quantity should be displayed in Lines in the same graph. X axis(Country) is same for these two . I am not sure how to achieve this. Please do let me know if anyone has solution for this.
    Thanks for your time.
    Thanks & Regards,
    Raja

    Hi Andreas,
      One word I can say is 'Perfect' . Even though I am out of office now,I hope the example perfectly will solve my problem.I will try it.
    Thanks for Aduri and Pcrao also for their suggestions .
    Thanks again and I assigned points to all to say my thanks
    Regards,
    Raja

  • Can combine two look and feel into new one?

    Hi,
    I want to change the JProgressBarUI of NimbusLAF on other LAF. I means how to put two different components each with different look and feel in single JFrame.Any way to get this. Help. Thankz.
    Edited by: user13383557 on Nov 22, 2010 12:07 AM

    How about reading the api doc and then message the appropriate method on the diverging component instance?
    It's not recommended, though, and wont survive dynamic LAF changes.
    CU
    Jeanette

  • How to combine two pages (not files) into one long vertical page

    Is there a way in Acrobat 9 Pro to combine (concatenate) say two 8.5"x11" pages and create a single 8.5"x22" page?
    Right now I'm having to do this by importing one page into Photoshop, extending the canvas, and pasting in the second page into the extended canvas space.  Very kludgy. While this works, saving the resulting PDF (even after removing the option to preserve editability in Photoshop) still results in a file which is a whopping 2.5MB in size as compared with around 25KB for the original PDF file which was spanning 2 pages.
    Ultimately what I'm trying to do is to be able to view a long document which was created in MS Word 2007 and then saved as a PDF, in a web browser by scrolling, without having page breaks.  Trying to increase the page dimensions is MS Word 2007 prior to creating the PDF worked to a point but Word 2007's maximum page length is 22 inches and as luck would have it, the document requires about 23 inches in length.
    I've tried using the custom page setting under the crop tool in Acrobat 9 but I can't seem to get the modified page dimensions to be accepted.  Acrobat 9 seems to accept the input and then nothing changes with the page's dimensions.

    A simple way to accomplish the job, though not recommended is to print the 2 page file to a new PDF with multi-up (assuming you select vertical rather than horizontal locations) and adjust the paper in the Adobe PDF printer to be 8.5X22. At least you might give it a shot. Some variation, along with rotation possibly, might work.

  • Combining two seperate pagemaker files into one pagemaker file.

    We are having done two seperate pagemaking files in two different systems. We are in need to combine/join these two pagemaker publications into one pagemaker publication. How to do this?

    There's several options.
    1. If the two publications are on different PCs, then create a PDF of each and combine them in Acrobat.
    2.Use the Book utility to combine the files when you print.  They need to be on the same PC.
    3. If the two publications are on the same PC (with all the necessary fonts and images), and the files are small, i.e. no more than a few pages, then open both publications in PM.  Tile the two publications side by side.  Add the required number of new pages to the first document, and have "New page 1" opposite "Page 1" of the second publication.
    With the pointer tool selected in the second publication, click Edit - Select All.  Then quickly drag all the objects acroos to "New Page 1" in the first publication.
    Do the same for the remaining pages - hence the requirement for not having too many pages.
    Use File - Save As to save the first publication with a new filename.  All links to images will be preserved.

  • I would like to combine two external hard drives into one?  How do I go about doing this?

    Hello:   In iPhoto I have an old external hard drive (EHD) with a photo library and a new one EHD with a photo library which has more space.  I would like to move all the photos from the old EHD to the new EDH.  Can you show me the steps to get this done so I don't lose any of my photos? I just want to use the new EHD only after the move.

    Connect both drives to your mac.
    Quit iPhoto, if it is runinning.
    If both your iPhoto libraries have the same name, rename one of them, perhaps "iPhoto Library 1.photolibrary" and "iPhoto Library 2.photolibrary", so you will not overwrite one of them, when you move them to the same drive.
    Select the library one in the Finder and drag it from the old drive to the new drive.
    Now launch iPhoto while depressing the option (alt) key and selecting the library in the new location. This way you can switch between the libraries.
    If you want to combine the two libraries into one single library, you will need another program. iPhoto Library Manager can merge libraries into one. 
    Download here: iPhoto Library Manager

  • How do I combine two groups of podcasts into one

    I have a particular podcast that I have been listening to for a long time (This Week in Tech). I decided to archive all of the episodes and pull them off of my machine. However, I have noticed that the first 20 or so are not grouped with the remaining ones. In iTunes if I click on 'Podcasts' in sidebar, the first 20 or so TWIT podcasts show up as a podcast called 'The Best Article Ever' where as the remaining 170 show up as they should as 'this week in tech'.
    I looked through all of the information in the 'get info' window and it does not contain the name 'The Best Article Ever'. However, if I 'Right-click' on one of the early podcasts, and select 'Show Description' instead of 'Get Info' then the resulting window shows up and indicates that the podcast name is 'The Best Article Ever'.
    I can not find any way to change this information in the 'Show Description' window.
    I am assuming that if I can, then the early podcasts will then be grouped with the newer ones.
    Any help if appreciated,
    John

    I found out how to do what I wanted and I'm giving my steps in hopes that it might help someone else.  I wanted to put several photos from a file onto a new blank image.  This is what I did.
    1.  Create a blank page.    File/New/ Blank File.   Put in the size.  I used 8x10.
    2.  Bring the photo  you want to use into Elements as you always do. It will list along the top next to the blank sheet.
    3.  Choose SELECT (top of screen)/ Select All.
    4.  Choose Edit/Copy   or Command "C"
    5.  Click on the Blank File.   Chose Edit/Paste  or Command "V"
    6.  Click on Image/ Transform or Command "T".  There should be a dotted line around your pasted image.  You can then move and adjust the image to how you want it.  When finished, press the check-mark on lower right of photo.
    7.   Repeat this with all the photos you want on the new blank file.
    8.  You will see on lower right of Elements,  the background layer and as many layers as you have photos.  These layers need to be permanently placed on the background layer. Go to Layers and press Merge Visible.  This will merge all layers to the background.
    9.  Save as and you are done.

  • How do I combine two I-tunes libraries into one?

    I have an I-tunes library and my daughter has her own.  We would like to combine them into one account.  She has her own account and log in a well as her own appple ID.  I also have my own but seems would make things easier to have one so we can share all of the apps and other things.    Instead of buying the same apps for my phone and then for her ipod touch it would make sense to have it all on one account

    Time flies Goldie.
    I'm back with MAC's any luck with merging.  I have a hundred's of CD's waiting to be downloaded to a hard drive but I just don't trust the constant updating with I-tunes.  The cloud is probably the solution and home sharing.

Maybe you are looking for

  • Using Time machine and external HD at the same time

    Dear All I'm intending to buy an external HD both for the purpose as a external HD and for time machine use. Is this possible? If so, how do I configure it? Thanks. Jojos

  • IDoc to Flat File in SAP PI 7.11

    Hi Experts, I am working on PI 7.11 and I have scenario from Idoc to Flat File. Idoc is posted from source side R/3 system.My requirement is "With out Converting the Idoc structure to XML Structure  i want to send the data to Target system i.e. File

  • MBP 2011 died and having problems reinstalling Mac OS

    Hello, Having problems trying to make my MBP start working again... Tech info: Early 2011 MBP, 10.6.6 preinstalled Mac OS X 2.3GHz Quad-core Intel Core i7 8GB 1333MHz DDR3 SDRAM - 2x4GB 256GB Solid State Drive SuperDrive 8x (DVD±R DL/DVD±RW/CD-RW) Ma

  • Language pack resource files in SharePoint 2010 and 2013

    Hi, We are translating the Language pack for SharePoint 2013 in Albanian language. Comparing to SharePoint 2010 resource files, there are less of them in SharePoint 2013 but they are bigger in size. Are they merged and in that case which of them are

  • How can I delay analog signal?

    I have an analog signal, the frequency is less than 1kHz. I want to get a delayed analog signal. Is it possible to realize analog delay generator using labview (daq card is PCI-6115)? I hope I could specify the delay time. Any suggestion will be grea