ArrayList(int initialCapacity) == why initial capacity not present ?

Hi,
I'm trying to create an ArrayList of initial size 5, and later on to set the first entry to a value :
List TrList = new ArrayList(5);
    System.out.println(TrList.size());
    TrList.set(0,4);
    System.out.println(TrList.get(0));When I run this I get :
0
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.set(ArrayList.java:337)
at vampstatistics.TransactionFileHandler.ReadGlobalDataAndWriteToFile(Main.java:58)
at vampstatistics.Main.main(Main.java:249)
Java Result: 1

The English word "capacity" refers to how much an object CAN hold, not how much it DOES hold. So an empty jug could have a 2-litre capacity, meaning that it could hold 2 litres of water.

Similar Messages

  • Why image is not present.

    I am using the following code for Splash screen.
    My image is not shown in JAR file? Why....import java.awt.*;
    import javax.swing.*;
    public class splashScreen{
         public static void showSplash(int deuration)
              JWindow splash = new JWindow();
              JPanel content = (JPanel)splash.getContentPane ();
              int width = 474;
              int height = 353;
              Dimension screen = Toolkit.getDefaultToolkit ().getScreenSize ();
              int x= (screen.width-width)/2;
              int y = (screen.height-height)/2;
              splash.setBounds (x, y, width, height);
              JLabel label = new JLabel(new ImageIcon("splashScr.png"));
              JLabel copyrt = new JLabel("My label text", JLabel.CENTER);
              copyrt.setFont(new Font("Copperplate Gothic Bold", Font.PLAIN, 11));
              content.add (label, BorderLayout.CENTER);
              content.add (copyrt, BorderLayout.SOUTH);
              content.setBorder (BorderFactory.createRaisedBevelBorder ());
              splash.setVisible (true);
              try {
                   Thread.sleep (deuration);
              }     catch(Exception e)     { JOptionPane.showMessageDialog (null,"Thread Sleep Error.\n" + e, "Error", JOptionPane.ERROR_MESSAGE);     }
              splash.hide ();
         public static void main(String[] args)
              showSplash(2000);
    }

    using winzip just u open that jar file and add ur image.
    regards
    pradeep

  • "send to Color" not present

    I just installed Final Cut 6. The "send to Color" is not an option from the send to section from the clip. Does anyone know why it is not present or how to fix the problem? Thank you!!

    If you haven't found any bugs in it yet, you will. I just finished a two-day training session, and we all experienced instability on some level. Even the instructor had things happen that weren't supposed to. Color promises to be one of, if not the most important piece of the FCP Suite. But it's no more stable than Motion 1 was. In fact, it might even be less so. Give it time. It will come of age.
    Why so many Apple users are so defensive is more of a riddle. Why the automatic "knee-capping" of anyone who uses the word "bug" or "glitch" in this forum continues to be one of life's eternal mysteries.
    All software has bugs and glitches. I've never seen a perfect program. If you use an application long enough, sooner or later, something will happen that isn't supposed to.

  • Like in widows you can refresh desktop by clicking right hand button and then select refresh.why it z not in mac

    like in windows some one can refresh computer by clicking right side of the mouse and then hit the refresh button.why it is not present in mac.is there no need for it to be refreshed?

    Correct, no need to refresh. Macs are smart enough to do that without any help.
    OS X is not like Windows, don't bring your Windows ways to it.

  • IPhoto not present after Leopard upgrade

    iMac upgrade to Leopard fails to install iPhoto
    Did an upgrade with format old data. Install appeared to be completed successfully. Went to import some photos and iPhoto was not present. Had installed the iWork suite as well and was under the impression iPhoto was on the OS disk.
    Any ideas why it is not present and how to install? Attempted download install and said not previous versions detected, aborted.
    Thanks for reply / help.

    reinstalled iLife08 and both iPhoto and iMovie icons came up on the bar. Appears to be there now and opens. CD looks fine but hearing a nice hum when installing like an abnormal spinning of the hardware.
    Thanks for the update. If you know of any issues with the original iMax core duo white, drop me a note as I do not believe it something tied to hardware and not the disk. The disk is a family pack upgrade and have never had the problem on another machine....
    Good day and thanks for the thread.

  • Why IndexOutOfBoundsEx on add( 3, "f" ) when set initial capacity ArrayList

    I created the below ArrayList (java 1.4.2_03) and it's throwing an out of bounds exception!
    ArrayList a = new ArrayList( 34 );
    //EVEN WHEN I USE THIS LINE, IT STILL THROWS THE EXCEPTION
    //a.ensureCapacity( 34 );
    a.add( 10, "something" );What could I be doing wrong? Is there a bug in 1.4.2_03?

    The initial capacity means the AL can hold that many elements without resizing. It doesn't mean there are that many elements currently in the list.
    You can't add at position 10 until you've added at least 10 elements (positions 0-9).

  • ArrayList initial capacity

    Hi again,
    I'm doing another exercise. I need to create an ArrayList with initial capacity. I'm doing this:
            List<Integer> l1 = new ArrayList<Integer>(10);
            System.out.println(l1.size());but putting 10 as an argument to the constructor doesn't set the initial capacity to 10, surprisingly. It prints 0. How can I set the initial capacity?
    Thanks,
    PR.

    Aardenon wrote:
    List<Integer> l1 = new ArrayList<Integer>(10);
    System.out.println(l1.size());but putting 10 as an argument to the constructor doesn't set the initial capacity to 10, surprisingly.Unsurprisingly, it does. Also if I remember correctly, 10 is the default initial capacity (although that's probably not specified anywhere).
    It prints 0.You're printing the actual size, not the initial capacity.
    Initial capacity just tells how much space there is in the list until it needs to expand (so if you know that you're putting a million objects in the list, you can create it with an initial capacity of a million to avoid the resizing required).

  • My MacBook Pro doesn't start; in safe mode shift CMD V the message "disk0s2: media is not present" is written on the screen repeatedly but the MacBook doesn't start.  Do you have any ideas of why this should be or what I should do to resolve this?

    My MacBook Pro doesn't start; in safe mode <shift CMD V> the message "disk0s2: media is not present" is written on the screen repeatedly but the MacBook doesn't start.  Do you have any ideas of why this should be or what I should do to resolve this?  Thanks  Eamonn

    Thanks for these suggestions: I have tried safe mode re-starts (both "verbose" and simple "shift" + power) to no avail.  I get the error message "disk0s2: media is not present".  Following this I inserted the installation disc and from there ran disc utility.  The "Verify Disk" indicated an error " invalid sibling link" which it could not repair.
    I also tried to completely re-format/erase the disk, but again got an error message "disk object invalid or unable to serialize".
    Any ideas of what could be causing this or the best solution?  I fear I am fast running out of options.

  • Java Interface does not accept method that passes ArrayList...Why?

    Java Interface does not accept method that passes ArrayList...Why?
    for example...
    public interface Interface extends java.rmi.Remote
    public ArrayList getSomething(String ID) throws java.rmi.RemoteException;
    Why is this not acceptable?

    Java Interface does not accept method that passes ArrayList...Why?for example...
    ALSO:
    You are not 'passing' ArrayList, you are returning it.
    If you are 'passing' anything, it is String.
    ~David

  • HT5622 I need help trying to figure out why I'm not able to purchase anythi iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

    I need help trying to figure out why I'm not able to purchase anything on iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

    I need help trying to figure out why I'm not able to purchase anything on iTunes. I changed my password, that didn't help. I changed my payment type, that didn't help. It initially started when my password got disabled. Any advice?

  • Why there is a SIP settings if VoIP is not present...

    Hello,
    Kindly ask you to explain subject of this post. There is SIP settings on my C5-03 but I can find how to make an internet call ! Moreover nothing about SIP in official attached phone manual.
    There is an advise to install "SIP_VoIP_3_1_Settings_S60_5_x_v1_0_en.sis" which will create additional menu like "Advanced SIP seetings" but it doesn't help in my case. Probably that old plugin just not capable with new C5-03.
    I can see that this is not only my problem. Please try to resolve this issue, it's very stupid to have SIP settings but not able to make internet VoIP call.
    Best regards,
    another department.

    Hello,
    Thank you for quick reply. But seems that you didn't read my post carefully.
    I have already perform SIP settings and made my phone registered with configured SIP profile.
    Problem is that I can't find how to make VoIP call after that.
    In Nokia E63 it was very simple After dialing the number you need just to choose voice, video or Internet call (using created SIP profile) option.
    But seems R&D just forgot to put it in call options.
    Also given link are leading to already installed "SIP VoIP Settings (SIP_VoIP_3_1_Settings_S60_5_x_v1_0_en.sis)".
    However mentioned  "Menu > Settings > Connectivity > Admin.settings > Net settings > Advanced VoIP settings > VoIP services"
    still not present.
    Same was indicated by other users, shown in my previous post.
    I'm sure that somebody from Nokia is present here, guys, just tell how to make VoIP call using already registered and configured SIP profile, so simple.

  • Ok Why Does Boolean NOT implement Comparable

    Ok.. im looking for a logical reason to why Boolean does NOT implement Comparable?
    Every other wrapper does. ( Integer, Double ect.. ) Just not Boolean..
    anyone got any logical guesses as to Why?
    ( just for context here is how i came upon this.. )
    I have a quicksort algorythm that reads in an arraylist and does some manipulation of it. All that is demands is that the objects in the list be comparable. This algorythm has worked beautifully (and fast) for serveral months.. till someone put a Boolean in the list.. doh!
    Thanks,
    JMG

    Using the collections.sort() would mean that each object would have to implement comparable anyways. It also means that these objects would only be sortable by one set of tests. I wish to sort my objects by any of their properties. Hence now my properties must implement comparable. ( given that this app usings mostly int, double and String its not a big deal) What surprised me was the Double did not implement comparable where all other wrappers did.. thats it..
    mostly i was just currious as to if there was a larger reason to why it was not implemented other than we just could not decided which should be valued higher :)
    JMG

  • Why it is not possible to install apps on an SD card on a Win 8.1 tablet?

    Why it is not possible to install apps on an SD card on a Win 8.1 tablet? If it is possible to install apps on SD card in Windows phone 8.1, why is it not possible on Windows 8.1? What sort of design philosophy you follow that gives better features on
    a mobile version of the OS but not on the parent OS? Kindly explain if you can!

    Hello,
    I'd ask in the
    Windows 8.1 forum on Microsoft Community.
    As the Microsoft Community is on a different platform, we cannot move the question for you.
    Once there, click on Participate near the top of the screen, and select 'Ask a Question' or 'Start a Discussion':
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • Hard Drive Capacity not Changing after moving files

    My internal hard drive capacity is shown at 249.58 GB and I only had about 1.97 GB available. I moved 122.89 GB of photos to an external hard drive partition plus many seldom used files and folders (not sure of the MB or GB size). Now my hard drive capacity shows 249.58 GB size with 2.36 GB available.
    Having moved more that 122.89 GB off my internal hard, why do I not have at least 122 GB available because I moved the photos to free up that space on my internal hard drive?
    How can I regain that space the photos used and/or why can't I regain it?
    Thanks for your help and suggestions.
    Vernon

    After posting the previous message, I remembered that I had not emptied the trash So, that is in the process of happening now since I copied the photos to the external drive and moved them from my internal hd to trash!
    I'll check on iPhoto's trash later.
    Thanks.
    Vernon

  • Got error(JS alert message) that "Given key was not present in the dictonary". After clearing history error gone. Not getting answer?

    I have asp dotnet website and when I am log in into it then I got an js alert message i.e.
    "Given key was not present in the dictonary". When I am going to clear clear browser history then it working fine without error. We know it thats why we are clearing history but client don't know and they dont want to clear history. So Is there solution
    of this problem. please suggest me.

    Hi Vishal Shivade,
    Please post in ASP.NET forums, where you could get better help.
    Thanks for your understanding.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • Cannot run application due to error deploying to IntegratedWebLog

    Hi, When I run a jspx file in Jdeveloper, I get errors as follow. How to delete the extra jar file? ========================================== *** Using port 7101 *** C:\Users\Administrator\AppData\Roaming\JDeveloper\system11.1.1.3.37.56.60\DefaultDo

  • While being idle online for a few minutes, why does Firefox start cyclically using 50% to 5% CPU resources, with a 10 to 1, hi to lo ratio

    This behavior became apparent after the last couple of Firefox version updates. Current Firefox version is 21.0. My PC is an IBM ThinkCentre running @ 3.0 Ghz Intel CPU with 1.5 Gigs PC3200 DDR ram. With or without any other Windows apps open, whethe

  • Upgrading Vista to Windows 7 problem

    So, I know Apple hasn't officially supported installing 7 yet, but I've been trying to upgrade from Vista Business edition. It will get almost all the way through and then have some kind of issue and says it reverts back to Vista. Has anyone else had

  • Upgrading from 9.2.2 to Jaguar

    Im in a bit of a situation...I got got the install disc 1 for jaguar to boot on my iMac DV G3 400 Mhz (9.2.2) but its stuck at the "Welcome to Mac OS X" screen. I cant get past the Introduction. At the bottom it says "Reading Pakages" but its been do

  • A few basic questions about NetWeaver

    Hi, I am really new to SAP and to NetWeaver, i usually work with ASP.net and other data sources, let me tell you a little bit of my scenario: Right now, i've changed job, and now I am facing a totally new environment, SAP is one of the things we use