Is this bizarre or am I expecting too much from Java language?

Yesterday I noticed that when I use Arrays.sort() to sort contents of an ArrayList (containing objects of Comparable type with compareTo implemented correctly) the sort routine did not return a sorted list. After looking at everything for hours the problem seems to be that the sort routine works on a copy of the original list created through ArrayList.toArray(). The Object [ ] that is the result of toArray() is sorted by the sort routine but it is never put back in the original ArrayList! So what is a person to do in order to use the list after it's sorted? Am I to switch to using Object [ ] instead of the original ArrayList or manually copy the sorted contents of Object [ ] into the original list ?
May be I'm missing something but this does seem a bit inconvenient and bizarre.
I would appreciate if someone could enlighten me and tell me of a better way if there is one.
Thanks in advance

Labelling your results "inconvenient and bizarre" may be a bit strong as both the Arrays.sort() and the ArrayList.toArray() methods do work as advertised. What you are probably missing is the fact that the ArrayList.toArray() method returns a copy of the array buffer that is used to store the actual elements of the given ArrayList. Part of the reason for this is that that internal array is often greater in size than the number of elements it holds; the ArrayList.toArray() returns an array that is exactly the size of the ArrayList (as opposed to the capacity).
As to a better way of doing things, check out the Collections class; it contains a collection of utility methods for the Collection extensions and implementations, much like the Arrays class contains utility methods for operating on arrays.
Shaun

Similar Messages

  • Premier Pro CS4, Am I expecting too much from my system

    I am editing a project that contains video from a live concert: 4 camera, hd, wide screen P2 files. MXF files. Anyhow, I've had better luck editing on my
    laptop i5 with 4 gigs of memory and an esata drive than on my desktop system outlined at the end of this message:
    I am using multi-camera mode to make my cuts. In multicamera it is jittery and eventually stops. If I play the timeline in the program monitor (not blown up) it works and plays the video with no problems. If I play it in full screen, it's jittery.
    I've been a PC guy for a long time but I've actually considered buying a mac pro and going final cut because I've spent days trying to debug this. Big investment! Any thoughts?
    I've experimented with putting the cache, scratch files, and project files on different disks with no better results.
    My virtual disk is currently 500gig, or 50000MB (I think I calculated that correct.) Anyhow, the minimum size number I input is 50000, and the largest size is the same.
    I have 6 gigs of memory.
    HELP!
    My system:
    Windows 7 Professional (x64)
    2.67 gigahertz Intel Core i7 920
    32 kilobyte primary memory cache
    Motherboard
    Board: ASUSTeK Computer INC. P6T DELUXE V2 Rev 1.xx
    3 drives, 1 tb each, system and one other drive on raid 0
    3rd drive is non-raid.
    All drives are 7200
    Raw Media is on non-raid disk.
    Memory
    6136 Megabytes Usable Installed Memory
    Slot 'DIMM0' has 2048 MB (serial number SerNum00)
    Slot 'DIMM1' is Empty
    Slot 'DIMM2' has 2048 MB (serial number SerNum02)
    Slot 'DIMM3' is Empty
    Slot 'DIMM4' has 2048 MB (serial number SerNum04)
    Slot 'DIMM5' is Empty
    Display
    NVIDIA GeForce 9800 GT (Microsoft Corporation - WDDM v1.1) [Display adapter]
    Samsung SyncMaster [Monitor] (19.9"vis, s/n H9LSA14300, October 2009)

    I'm trying to figure out how to give you a screen shot of my taks manager. But, in the meantime, can you look at the following?
    Okay, Each time I move the scratch files, I get results. Not the most optimal results but I think that this might be the key to get me going. Here's my setup:
    3 1 TB drives
    C: Windows and premier Pro
    E: This is an empty disk that I can use that is raid 0 with C:
    F: Contains my raw video files, Non-raid
    Consider the following and note my questions (WHERE....?) with relation to my setup above.
    In Premier Pro
       Edit->Preferences->Media
           Media Cache Files   (WHERE SHOULD I PUT THESE?)
           Media Cache Database  (WHERE SHOULD I PUT THESE)
       Project->Scratch Disks
           Captured Video (WHERE SHOULD I PUT THESE?)
           Captured Audio (WHERE SHOULD I PUT THESE?)
           Video Previews (WHERE?)
           Audio Previews (WHERE?)
    Thanks for the help!
    Tim

  • Am I expecting too much?

    Hi,
    I'm a back-again user of iMovie. The last version I used was back in 2003. It worked okay, but had its issues. I learned of the non-destructive editing available in the current versions of iMovie and came rushing back.
    My question is about the performance of the software. I note an annoying lag with skimming and when watching the video in the preview pane. The skimming is certainly not fluid like it is in the demo videos Apple is showing and when previewing my project, when switching between clips, the preview hiccups and I lose about 2-4 seconds of video (the sounds chugs along fine). Additionally, any transitions I put in barely show up at all, and the video freezes for the duration of the transition, plus a few ticks. Everything exports properly when I render a final video, but the preview problems make editing a bit painful.
    The stuttering during skimming is most irritating, especially when trying to select a clip by dragging. I've upgraded my memory (now 4GB), tried an account that has almost nothing loaded (loggged off all other accounts), checked for persmission problems, even tried moving the projects to my external RAID over a FW 800. Nothing is really helping.
    I am running a MB Pro 2.2 GHz Core 2 Duo. I have 36 GB of free space on my internal (system) HDD. Is this just the way the software is? Am I expecting too much from an inexpensive video editor? Any suggestions on what do to?
    Thanks for all your help.
    Kevin

    Hi
    *Not knowing the origin to Your problem - General approach when in trouble is as follows:*
    • Free space on internal (start-up) hard disk if it is less than 10Gb should rather have 25Gb
    • Hard disk is untidy: Repair Permissions, Repair Hard disk (Apple Disc Util tool)
    • Garageband-fix. Start it and Close it. Re-try
    • Delete iMovie pref file - or rather start a new user/account - log into this and re-try
    iMovie pref file resides:
    Mac Hard Disk (start-up HD)/Users/"Your account"/Library/Preferences and is named: com.apple.iMovie.plist
    While iMovie is NOT RUNNING - move this file out to desk-top.
    Now restart iMovie.
    • Third party plug-ins that doesn't work OK (not relevant for iMovie’08)
    • Program miss-match: iMovie 5.0.2, up to Mac OS X.4.11 AND QuickTime 7.4.1 - is OK
    • Program miss-match: iMovie 6.0.3 or 6.0.4, Mac OS X.4.11 AND QuickTime 7.4.1 - is OK (might work under Leopard)
    • Program miss-match: iMovie’08 v. 7.0.1, Mac OS X.4.11 AND QuickTime 7.4.1 - is OK (might work under Leopard)
    • Screen must be set to Million-colors
    From LKN 1935: (in this case = iMovie HD (5), I tried it all, but nothing worked.
    Your answer (above) has been helpfull insofar as all the different trials led to the conclusion that
    there was something wrong with my iMovie software. I therefore threw everything away and reinstalled
    iMovie from the HD. After that the exportation of DV videos (there has not been any problem with HDV videos)
    to my Sony camcorders worked properly as it did before.
    I also turn off "FileVault" and try to get SpotLight to do as little as possibly
    during editing.
    • So all other programs that can run in background eg Internet access and so on
    • Keeping as few external hard disks running.
    • The external one ONLY FireWire - NO USB/USB2
    Yours Bengt W

  • Garage band results cheesy? Am I expecting too much?

    For eg: more often than not I'll download a midi and it will sound great played through quicktime.
    When I open it up in Garage band often the file will sound different, some instruments sound
    different or the temp may be different. A lot of the time the end result sounds pretty cheesy.
    The way I create a Garage band project is create a new project, drag the midi to the garage band
    and start editing. Seem to be limited to very few instruments too. For eg there are only about 5
    drum kits, 2 useable for what I need Pop and rock and both sound fairly ordinary.
    I find the bass a little average too. Quite often it is way too low down in the scale and sounds
    awful. I generally find the fingerstyle bass the only useable one.
    Is there anywhere to get more instruments etc? or am I expecting too much from a non pro program.
    Would I be better off with cakewalk or something like that?
    Any help appreciated

    fender22 wrote:
    Is there anywhere to get more instruments etc?
    try out some SoundFonts (5,000 ish):
    http://www.bulletsandbones.com/GB/PlugInsSoundFonts.html
    how to install them (short story):
    http://www.bulletsandbones.com/GB/GBFAQ.html#installsoundfonts
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    how to use them (short story):
    http://www.bulletsandbones.com/GB/GBFAQ.html#usesoundfonts
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    install and use tutorial (the long hand-holding story):
    http://www.bulletsandbones.com/GB/Tutorials.html#allaboutsoundfonts
    (Let the page FULLY load. The link to your answer is at the top of your screen)

  • Maybe I'm expecting too much of the new MBP...

    Maybe I'm expecting too much of my MacBook pro...
    Earlier I was on the Early 2011 MBP and it just seemed to lag. I had a 2006 MacBook up until recently and I don't see a difference hardly at all.
    I was on firefox running maybe 10 tabs, and had a few other applications open, and it was very sluggish and lagging. Seemed to have the rainbow spining thing come up constantly.
    Am I expecting too much? Or do I have a lemon?

    You should notice a significant difference between a MBP and an older MacBook. RAM would be my first thought - look under the Apple menu for About this Mac and see if it actually registers the 4GB of RAM. Second, how much of your hard drive is in use? If you've filled it up with video, music, and pictures it might be too full so that there isn't enough room for swap files and caches.
    Also, if you migrated all your applications from the old computer to the new you might have migrated some applications (especially startup items) that are incompatible. To see if this might be the problem, create a new account and boot into it. If the new account feels peppier you'll know the problem exists in your user account.

  • Maybe I'm expecting too much?

    Maybe I'm expecting too much of my MacBook pro...
    Earlier I was on the Early 2011 MBP and it just seemed to lag. I had a 2006 MacBook up until recently and I don't see a difference hardly at all.
    I was on firefox running maybe 10 tabs, and had a few other applications open, and it was very sluggish and lagging.
    Am I expecting too much? Or do I have a lemon?

    You should ask in the forums for newer MacBook Pros (Late 2008 and later) here:
    http://discussions.apple.com/category.jspa?categoryID=251
    You're in the forum for the older MBP like your first--more people with experience with a 13-incher will be in the other forum

  • You cannot embed this FLV file because it consumes too much memory. Could sb help with this problem?

    You cannot embed this FLV file because it consumes too much memory. Could sb help with this problem?

    The error is pretty concise. Do you know how to re-encode the video smaller?

  • Did I expect too much?

    Greetings, I upgraded to this new iMac G5 from 2 year old iMac G4. I thought this thing would be much much quicker. On some things it is quicker. On many things it is not. Opening apps isn't any faster and neither is moving data across the front side bus. Were my expectations too high. Is the real gain I find really in the heavy CPU tasks?

    I upgraded from a TiBook 1ghz to the newer 20" G5 IMac knowing I would get an increase in speed, and assuming I would not have an over-heating CPU problem which led me to purchase the IMac in the first place. (My TiBook never had a problem or froze from heat until I installed Tiger.) Low and behold, I'm measuring my new IMac CPU at over 190 degrees! When its cool, it's zippy; but as soon as the temp starts to rise, things slow down and I shut down fearing I will burn something up. I put cloth wrapped frozen ice paks underneath, and a frozen cloth/crystal sling doo-dad on top. From what I've read over the past couple of days (while searching for a unique solution to this problem), heat has a tremendous bearing on speed. Where is the slim low profile horizontal white plexiglass enclsoed bank of mini-fans that one can attach to the back of the IMac (or underneath). Perhaps a perforated screen vent on the back would be better. I am considering sending my machine back for a refund as I've only had it three weeks. P.S. My first Mac, a PowerMac 7500/100 purchased new in Oct '95, would run for days w/o shutdown - never gave a thought about overheating.

  • Why do I have to run the plug-in container in my processes constantly in this version? It takes up too much memory!

    The earlier version of Firefox did not run this plug-in container. Every time I would remove it from my processes it would kill videos etc. But, it was all fine in the older version of Firefox, so why the change? So I chose not to update Firefox. Then, the other day, I saw that is was automatically downloading and I turned off my computer because it wouldn't stop and I didn't give permission. When I got home I could not use Firefox and it took me hours to figure out how to get the internet back. Then I got Firefox back and this stupid process is running again. It takes up too much memory. I don't like a bunch of extra processes running like that. So, why can't I just use the old version? Is this process absolutely necessary?

    In the past the memory usage would end up as part of the Firefox program. Now with OOPP you can see it as a separate process and that makes it more noticeable.
    You can disable OOP if you want.<br />
    See http://kb.mozillazine.org/Plugin-container_and_out-of-process_plugins
    Your above posted system details show outdated plugin(s) with known security and stability risks.
    # Shockwave Flash 10.0 r42
    # Next Generation Java Plug-in 1.6.0_18 for Mozilla browsers
    Update the [[Java]] plugin to the latest version.
    *http://java.sun.com/javase/downloads/index.jsp (Java Platform: Download JRE)
    Update the [[Managing the Flash plugin|Flash]] plugin to the latest version.
    *http://www.adobe.com/software/flash/about/
    I don't know if these three with different copyright dates are all needed:
    # Version 0.9.17, copyright 2008-2010 Veetle Inchttp://www.veetle.com/
    # Version 0.9.17, Copyright 2006-2009 Veetle Inchttp://www.veetle.com/
    # Version 0.9.17, copyright 2006-2010 Veetle Inchttp://www.veetle.com/

  • Contact sheets. Am I asking too much from LR

    In my workflow I need to get 'printed' contact sheets out ASAP for public to look at, note file numbers, then view on screen > hopefully purchase.
    I have produced a contact template 16up and on average we print 10-18 sheets at a time.
    The time it takes to print is not viable (anything from 2 minutes (rare) - 20 minutes, average 15 mins +)
    I have set to draft mode printing, increased my RAM to 12GB (from 4)
    and the average file is about 3000 pixels.
    I have set the Activity Monitor (Mac 10.8.4) to watch and there seems to be no 'page outs'
    and the CPU and free space seem to be within their limits.
    I have also tried to PDF and to Jpeg file, but this seems to take as long.
    Also tried on LR3, LR4.4 & LR5 Trial, no difference.
    Am I asking too much of my OS or LR.
    Any input appreciated
    Thanks
    P.S.
    saw 1 or 2 other posts suggesting Draft Mode made a massive difference even to big files, but not to mine.
    Pages seem to load fairly quick at first, then hang.
    May be my imagination, but the time to print seems to be increasing

    After much searching I think I may have found the solution ?
    We were creating 1:1 previews by editing the photos before printing to contact sheets.
    The 1:1 Previews is what seemed to be causing the hold up.
    So to remedy this
    In Library > Library Menu > Previews > Discard 1:1 Previews > All photos
    It then printed out the contact sheets at a fair rate of knots.
    (I believe once you go back to loupe and zoom in, it then creates the 1:1 Preview again)
    22 pages with 349 images ave. 3,500 pixels per photo = 12 seconds (compared to 20 mins to never),
    obviously + printing time.
    Quick silly question though ??
    I take it if I have minimal preview settings this will not infringe the quality of the larger printed copies ?
    (I take it, it is just that, a preview ?)
    I would also have thought that LR would have found a solution to this before now
    or at least provided some sort of info / tutorial / remedy.
    Looking at the results from people having problems with this goes way back to LR2/LR3.

  • Itunes deducting too much from my prepaid balance?

    Hi! 
    Just like the question states, I think that the Itunes store is deducting too much when I'm ordering apps in the app store. I have a total of $75 prepaid credits and bought apps that totals $9.95 (Got this from my purchase history). Deduct that from 75 gives me $65.05 dollars left. However, it says that I have 63.07 dollars left in my account. Please, can anyone help me ASAP??? I want my missing credits back, even though it was only $1.98!! Thanks in advance.

    Deduct that from 75 gives me $65.05 dollars left. However, it says that I have 63.07 dollars left in my account.
    You need to take into account any applicable taxes and or fees.
    "Your total price will include the price of the product plus any applicable sales tax; such sales tax is based on the bill-to address and the sales tax rate in effect at the time you download the product. We will charge tax only in states where digital goods are taxable."
    From here >  iTUNES STORE - TERMS AND CONDITIONS

  • Am i asking too much from my airport express?!

    I have a belkin wireless ADSL router set up so that I can use my laptop anywhere in the house. I also wanted to print from anywhere and listen to iTunes on the stereo downstairs. Airport Express seemed perfect. I set it up as a client no problem and I can print and listen to music fine.
    BUT I also have an X-box downstairs and wanted to connect it to the internet using the ethernet port on airport express. Didn't work. (hard-wiring it to the router works fine by the way)
    Am I simply trying to get my airport express to do too much? Is there a way round this?
    Thanks
    Dan
    Powerbook G4 12 (867MHz)   Mac OS X (10.4.5)  

    If you have a router that supports WDS, that doesn't automatically enable it. If you are connecting by using "Join existing network" the ethernet port always gets disabled.
    Once you set up the router to use WDS by going to the WDS tab, which will be available once you change "Join network" to "Create new network" (I know, this is a bit misleading, but it's what you need to do.). You might need to add the MAC address manually, but you can try searching for your base station.
    Even after you have a WDS set up, you might still need to enable the ethernet port by going to the "base station options" and turning it on. It should default to on though.

  • How to call c functions that expects c structs from java program?

    i need to call from my java program to c functions that get
    c structs as a parameters in their prototype.
    as you probablly know java is not working with structs (classes only), so my question is how can i do it , i mean call the c functions that gets structs as parameters form java????

    i believe your c function can accept a jobject and then inside your c function you have to translate that jobject into a c struct by using the jni methods.
    the only reason your c function cant accept structs from java is because java does not have such structures. your c function can accept any data type that has been defined and a jobject has been defined.
    if you have no control over the c functions that are being called, you need to write a wrapper function for those c function. the wrapper functions do the translation from jobject to a struct...then call the c other c functions.

  • After Effects Ram Preview Drops Frames , Using Strangely Too Much Ram

    System Specs :
         CPU : Core i7 4770k
         Memory : 16 GB DDRIII
         Graphic Card : GTX 770 4GB RAM
         Storage : 256 GB SSD + 2 TB HDD
         OS : Windows 7 SP1
         Using After Effects CC 12.2.1.5
    NOTE : NOT ANY ADDITIONAL HARDWARE IS ATTACHED TO MY PC . NO SOUND RELATED EQUIPMENT NOR CAPTURE CARD NOR ANY THING ELSE
    Hi there
    As you Already Don't know I'm an After effects Specialist Using it for quite long time . There is an Ancient Problem with CS6 CC versions . I have a short Small size 1080p Video , about 8 MB , I drag it into project panel and then put it into timeline hence it creates a sequence . There are no Effects and nothing added to timeline , just a small simple video . The Strange Problem is when I click "0" for ram preview , The video starts playing and the green bar above timeline starts to fill . When Ram preview Finishes and plays the video from beginning I See there are several frames Between which are not being loaded to Ram ! The video plays RGB color bar instead of main video and when I check the Green bar above Timeline I see that those frames are being dropped and there is no Green bar above them !
    I have had this problem several times before but this time it is too important and the problem should be solved . What is obvious is that some frames are not being rendered or are being deleted after render !
    Another Strange problem is that when I open Task manager , It shows AE uses around 10 GB ! of RAM when I press "0" for Ram previewing this video !
    So there is a Logical explanation here , Somehow when I do ram preview this video it uses extra ordinary too much ram so AE is unable to load the full video (8 MB) into Ram and hence deletes some of frames .
    most of my videos have not this problem and use acceptable amount of ram .I've had this issue with some of my videos till now .
    Listen carefully : "This has nothing to do with AE preferences or low memory or plugins . because there is nothing wrong with any individual components of may hardware or software . I have far more than enough RAM for a 8MB video . My Memory has no hardware or software problem . I tested them and if there was any problem with memory or other hardware that should have affected other applications . I have the most recent AE version . I have the most Recent windows updates and drivers . I have a Clean virus free system , and as a computer engineer this strange AE problem is rarely caused by viruses , trust me . I have not any hardware instead of ones a normal PC has . I have not any problem with my whole entire system configuration because I have benchmarked my PC with several up to date softwares . I have tested my PC with almost any STRESS TESTING solutions available for really long period of time , 3 days by IDA64 . Not any driver conflict , dll missing , registry problem have been discovered , as I know perfectly how to solve them ."
    I asked some of my friend whom are expert in AE . I handed them my videos and Watched ALL OF THEM HAD THE SAME ISSUE ! So the problem isn't related to my Local PC . What i believe is that there is some malfunctioning or miss coded part in AE source code that decides to reserve such a huge strange amount of ram for such a tiny 8MB video . The point is that the AE works fine , no crash or any problem report . So the AE it Self decides to allocate such huge amount of ram and thinks it is correct ! So I think this is a work around that AE developers in adobe are using to bypass a problem or conflict ! by Using more amount of RAM . I think that there might be some miss understanding between the AE and my installed codec . I installed MEGA CODEC PACK on my PC to enable some new codec supports , and so are some of Windows default de/encoders changed to new ones . I think there shouldn't be any problem But there is something wrong between AE and de/encoder modules !
    Please any one with any suggestion , I really appreciate your advices .

    ###UPDATED###
    Well thank you guys for your patience ...
    as you considered I forgot to mention the codec itself and other stuff ...
    The video is in 1080p , 35 sec long , it is a green screen shot , this video is directly downloaded from YouTube and plays perfectly on all tested PCs . here are detailed info :
    Format                                   : MPEG-4
    Format profile                          : Base Media
    File size                                 : 8.55 MiB
    Duration                                 : 34s 993ms
    Overall bit rate mode                : Variable
    Overall bit rate                         : 2 050 Kbps
    VideoFormat                            : AVC
    Format/Info                              : Advanced Video Codec
    Format profile                           : [email protected]
    Codec ID                                 : avc1
    Codec ID/Info                            : Advanced Video Coding
    Bit rate                                    : 1 927 Kbps
    Width                                      : 1 920 pixels
    Height                                     : 1 080 pixels
    Frame rate mode                      : Constant
    Frame rate                               : 30.000 fps
    Color space                              : YUV
    Chroma subsampling                 : 4:2:0
    Bit depth                                  : 8 bits
    Scan type                                 : Progressive
    NOTICE : This video is just for testing the lighting and etc , and so the Sampling and other specs are not considered for broadcast .
    I think you hit the point ! Thats K-lite codec pack installed on every machine which the video is tested on ! The point is whats wrong with it ?! I have had never ever any problem with this codec pack !!!
    The deadly question : So what are the alternative ways to work with codecs that AE doesn't support ?! because installing codec looks simple and sufficient !

  • Application diagnostics taking too much time

    EBS Version : 12.1.3
    Application diagnostics taking too much time. How do i investigate why its taking too much time? and then also I want to know How do i cancel this request?

    Application diagnostics taking too much time. How do i investigate why its taking too much time? and then also I want to know How do i cancel this request?
    Is this happening for all diagnostics scripts or specific one(s) only?
    E-Business Suite Diagnostics Installation Guide (Doc ID 167000.1)
    E-Business Suite Diagnostics References for R12 (Doc ID 421245.1)
    E-Business Suite Diagnostic Tools FAQ and Troubleshooting Guide for Release 11i and R12 (Doc ID 235307.1)
    You can it from OAM and you might need to cancel the database session from the backend as well.
    Thanks,
    Hussein

Maybe you are looking for

  • How do I set up a second itunes account on the same laptop?

    Can you have 2 separate itune accounts on the same laptop? How do you set it up?

  • Can't get my printer to work with new OSX 10,6?

    I upgraded to snow leopard 10.6.3 so I could use the new Touch 4th generation. Everything was great until I tried to use my epson R2880! I keep getting errors. It also says the printer is not registered. I have downloaded software updates, font updat

  • EP 6.0 SP2 MSS ITS Logout

    We have implemented MSS in an EP 6.0 SP landscape.  There are some aspects of MSS that still use ITS, even in the portal.  I am having some trouble closing the ITS browser window when a users launches an ITS session from MSS.  The exiturl is working

  • Can't import an .AI containing editable text

    I am using Flash CS3 (v.9.0.2) on MacOSX (v. 10.4.11). When I try to import an .AI that contains editable text (not outlined text), the import dialog box doesn't come up and I have no artwork on the stage or in the library. I do not get any kind of a

  • Display a document.html in a frame java

    how can I display a .html in a frame java ? could it be possible to obtain a object Graphics to put it then in the frame ?