I created a vector and added objects, but the vector is empty

I created an object called a facility, it accepts 2 strings in the creator but stores the data as a string and a float. as you can see from the code below, i have tried to create a vector object to contain facilitys and named it entries. when i add objects to this vector, the vectors size does not change, and i cannot access elements of it via their index. but when i print the vector out i can see the elements? what is going on here. i am very confused. ps, if it helps i havent worked with vectors much before.
FacilitysTest.java
import java.util.*;
public class FacilitysTest {
     public static void main (String [] args) {
     Facilitys entries = new Facilitys();
     entries.add("Stage","3.56");
     entries.add("kitchen","5.00");
     entries.add("heating","2");
//     System.out.println(entries.firstElement() );
     System.out.println("printing out entries");
     System.out.println(entries);
     System.out.println();
     System.out.println("There are "+entries.size()+" entries");
     System.out.println();
     System.out.println("modifying entry 2");
     entries.setElementAt(new Facility("lighting","1.34"), 2);
     System.out.println(entries);
     System.out.println();
     System.out.println("deleting entry 1");
     entries.remove(1);
     System.out.println(entries);
}the following is what happens when i run this code.
the number (0,1,2) is taken from a unique number assigned to the facility and is not anything to do with the facilitys position in the vector.
printing out entries
Facility number: 0, Name: Stage , Cost/Hour: 3.56
Facility number: 1, Name: kitchen , Cost/Hour: 5.0
Facility number: 2, Name: heating , Cost/Hour: 2.0
There are 0 entries
modifying entry 2
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 >= 0
at java.util.Vector.setElementAt(Vector.java:489)
at FacilitysTest.main(FacilitysTest.java:17)
Press any key to continue . . .
Facilitys.java
import java.util.*;
public class Facilitys extends Vector {
     private Vector entries;
     public Facilitys( ) {
             entries = new Vector();
    public void add( String name, String price ) {
         entries.add((new Facility( name, price) ));
    public Facility get(int index) {
          return ((Facility)entries.get(index));
     public float total() {
          float total = 0;
          for (int i = 0; i<entries.size();i++) {
               total = total + ( (Facility)entries.get(i) ).getPricePerHour();
          return total;
    public String toString( ) {
        StringBuffer temp = new StringBuffer();
        for (int i = 0; i < entries.size(); ++i) {
            temp.append( entries.get(i).toString() + "\n" );
        return temp.toString();
}

are you reffering to where i have public class
Facilitys extends Vector {
     private Vector entries;
     public Facilitys( ) {
             entries = new Vector();
That's correct. That's your problem.
i added the extends Vector, because without it i got
the following errors
C:\Documents and Settings\george\My
Documents\University\JavaCode\CM0112\FacilitysTest.jav
a:14: cannot find symbol
symbol : method size()
location: class Facilitys
System.out.println("There are "+entries.size()+"
" entries");That's because you haven't implemented a size method in your class.
^
C:\Documents and Settings\george\My
Documents\University\JavaCode\CM0112\FacilitysTest.jav
a:17: cannot find symbol
symbol : method setElementAt(Facility,int)
location: class Facilitys
entries.setElementAt(new
w Facility("lighting","1.34"), 2);That's because you haven't implemented setElementAt in your class.
C:\Documents and Settings\george\My
Documents\University\JavaCode\CM0112\FacilitysTest.jav
a:21: cannot find symbol
symbol : method remove(int)
location: class Facilitys
     entries.remove(1);
^That's because you haven't implemented remove in your class.
/Kaj

Similar Messages

  • Adobe Premiere Basics Creating Video Publishing and Adding advertisments within the video.

    Hi I am new to Adobe Premiere and have some basic questions I have a video that I would like to mix sound into and also add a flash advertisment in but am having problems previewing the movie in perfect quality.  For example, when I drag my imported video in, the movie gets much smaller when I preview it.  Even after I get some of the sequences finished and I export it, the video looks small.
    I think this is something in the publishing or importing features that I don't know of, basically how do I work on my video and create parts to it while keeping the quality of the video 100%
    My second question is, I have created a simple fade in fade out advertisment that I would like to go in the bottom right part of the video, how do i position it exactly there?
    thanks pros!

    1 - See 2nd post for picture of NEW ITEM process http://forums.adobe.com/thread/872666?tstart=0
    2 - Read about PIP = Picture in Picture
    CS5 User Guides - online and PDF (see link in upper right corner at individual pages)
    http://blogs.adobe.com/premiereprotraining/2010/08/help-documents-for-creative-suite-5-pdf -and-html.html

  • I am trying to create a QR Code in cs6 but the option is not available under objects

    I have cs6 - i should be able to create a qr code under objects but the option is not there...

    See: [Ann] QR code for Indesign CS4 and up
    http://forums.adobe.com/message/5442405#5442405

  • UPS delivered my iPhone 6 but the box is empty!

    My iPhone 6 was supposed to be delivered on 19/9, and it did, but the box was empty and my friend (who signed the package, and whom I trust) found that there was some signs it was tempered with.
    I sent a Lost package claim to UPS, still trying to call apple. What else should I do? Is there any support email address from Apple that I can send my case to?
    Tks a lot.

    The same thing happened to me today and I AM LIVID!! I am trying to figure out how any company can send a whole package with everything but the phone? I could maybe entertain a charger or headphones being missing, but the phone....seriously!! What kind of quality control do they have? Is someone not double-checking to determine if the boxes have all the materials that they are suppose to have....I mean when you have people paying $200-1000 for phones, you would think that the box would be checked to make sure that it actually contains the purchased materials...aren't the boxes checked for weight or something.. I called Apple and now I have to wait 48-72 hours for them to do an investigation, and then they will determine how long it will take to get me a new phone.....to be honest, a new phone should be shipped to me NOW while they conduct their investigation.....why should a customer have to wait because of their company's mistake? Apple's compliance department should really have a better system for dealing with incidents like this.......I'm trying to determine if I am more upset about this or the time I had to buy 3 computers to get one, and they told me they would retrieve the information from my computer and they didn't....in that case one rep told me that I just had to deal with their mistake and be an adult( I politely explained that I was a law student with finals the next week--that didn't matter to him) , the other tried to mitigate that situation and give me a external disk drive as a peace agreement when I called to cancel my order....some great gift. *sarcasm* However, i do appreciate her kindness.

  • Vector and my object??

    hi all,
    I am reading a binary file, then creating the object and adding that object in my vector. How can i get it back according to its id? let is say i added all the customers read from file and now i want to get customer 3?
    int thisId=dis.readInt();
    String thisName=dis.readUTF();
    double thisBalance=dis.readDouble();
    Customer cus=new Customer(thisName,thisId,thisBalance);
    cusList.add(cus);
    abdul

    Best possible way is to use Hashtable and put customerid as key and Customer object
    as value.
    Modify your code with,
    Customer cus=new Customer(thisName,thisId,thisBalance);
    some-hashtable-object.put(thisId,cus);
    now if you want to take particular Customer
    use
    Customer c = (Customer)some-hashtable-object.get(any customerid);
    Now if you don't want to use Hashtable and continue with Vector then you have to iterate the,
    Vector and whether object has id 3 .
    like
    for(int i=0;i<Vectorobject.size();i++){
    Customer c = (Customer) Vectorobject.get(i);
    id = c.getCustomerId() // or any method you have to get id;
    // check it....
    But i think Hashtable is the better way to use here.
    I think you understand what i want to say .
    Tarak.

  • Cannot send or receive yahoo mail or gmail from iPhone . installed ios 6 recently. tried rebooting the phone and deleting the email account and adding again but nothing works ! can someone suggest a solution?

    cannot send or receive yahoo mail or gmail from iPhone . installed ios 6 recently. tried rebooting the phone and deleting the email account and adding again but nothing works ! can someone suggest a solution?

    Not sure about yahoo, but for gmail, I done the following:
    Set up using Exchange on iPhone, it'll keep prompting for password.  On PC use captcha option, log in to gmail account from PC after completingg captcha option, enter password on iPhone.
    See how that goes for gmail, let us know.
    Hopefully someone will have fix for yahoo.

  • I updated to ios 5.1.1 and added icloud services. the problem is now whenever i connect my iphone to my PC, itunes does not recognize my phone. i need it to but it just does not connect..

    i updated to ios 5.1.1 and added icloud services. the problem is now whenever i connect my iphone to my PC, itunes does not recognize my phone. i need it to but it just does not connect..

    Try the standard fixes to rule out a software problem:
    - Reset. Nothing is lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Restore from backup
    - Restore to factory defaults/new iPod.
    If you still have the problem that points to a hardware problem. Yu can make an appointment at the the Genius Bar of an Apple store or try:
    fix for Home button

  • My business partner signed up for the acrobat xl pro, and added me to the account.  it send me an email to download and install, but after it downloads, nothing happens, can't double click on it to open, it just does nothing on the double click.  I tried

    my business partner signed up for the acrobat xl pro, and added me to the account.  it send me an email to download and install, but after it downloads, nothing happens, can't double click on it to open, it just does nothing on the double click.  I tried to download again, and still same thing.  I am on a mac with latest OS.  Does anyone know what I am doing wrong?

    he is on a pc, we bought a subscription to the license and was told it's 180 a year or 14.99 monthly per user, on the business plan.  So the sales rep on the phone walked us through adding the people who will be added to account who will need a license to use.  the sales rep said that we just need to go to that section and add users and it will email the user a link to download the file and install

  • HT1277 I can't seem to get gmail from my apple mail account. I have removed the account and added it, but it says I have the wrong password. I close gmail and get in just fine. What's up?

    I can't seem to get gmail from my apple mail account. I have removed the account and added it, but it says I have the wrong password. I close gmail and get in just fine. What's up?

    I meant that I sign out, sign back in ok. Ergo, I know my password. Someone here on the support page  (you?) told me the culprit is the 2 step verification process which I had on. That makes a lot of sense as Apple mail won't get a code thereby jamming up the process. I could not even start a new account until I took that 2 step process off. Everything fine now thank you.

  • HT1338 I can create bookmarks folders and populate them. but when i quit safari the folders disappear?

    I can create bookmarks folders and populate them. but when i quit safari the folders disappear?
    Please  help

    Hi Nick ...
    Try deleting the cache and reset ...
    From your Safari menu bar click Safari > Empty Cache
    If that doesn't help, back to the menu bar, click Safari > Reset Safari. Select the top 5 boxes, click Reset.
    If that didn't help, try troubleshooting the Safari .plist  (preferences)
    Quit Safari.
    Go to ~/Library/Preferences
    Move the com.apple.Safari.plist file from the Preferences folder to the Desktop.
    Relaunch Safari.
    If it's working ok now, move that .plist  file to the Trash. If not, move it back to the Preferences folder.
    If you have trouble finding those files, open the Finder. From the Finder menu bar top of your screen, click Go > Go to Folder
    Type this exactly as you see it here:   ~/Library/Preferences
    Click Go

  • I have read up on all about crashes and i cant even open it in safe mode :( i have tried deleting it and reinstalling it but the problem still persists. What would you suggest i do and is there any way i canget hold of firefox 6 for mac?

    i have read up on all about crashes and i cant even open it in safe mode :( i have tried deleting it and reinstalling it but the problem still persists. What would you suggest i do and is there any way i canget hold of firefox 6 for mac?

    Does the regular Firefox 8 release version work or does the version crash as well?
    *Firefox 8.0.x: http://www.mozilla.com/en-US/firefox/all.html
    Create a new profile as a test to check if your current profile is causing the problems.
    See "Basic Troubleshooting: Make a new profile":
    *https://support.mozilla.com/kb/Basic+Troubleshooting#w_8-make-a-new-profile
    There may be extensions and plugins installed by default in a new profile, so check that in "Tools > Add-ons > Extensions & Plugins" in case there are still problems.
    If that new profile works then you can transfer some files from the old profile to that new profile, but be careful not to copy corrupted files.
    See:
    *http://kb.mozillazine.org/Transferring_data_to_a_new_profile_-_Firefox

  • Why can't I open the filter gallery in Photoshop CC 2014? I've converted the photo layer into a smart object, but the filter gallery selection is still grayed out.

    Why can't I open the filter gallery in Photoshop CC 2014? I've converted the photo layer into a smart object, but the filter gallery selection is still grayed out. How do I make it active?

    Please go to Help, System Info and Copy then paste here.
    Benjamin

  • Design option missing for Fluid Grid layouts (was:In dreamweaver CC, I created a new fluid grid page, but the options to edit the page...)

    Hi, in dreamweaver CC, I created a new fluid grid page, but the options to edit the page are limited to code / split / live. The design optin is missing and I need it to move around the fluid grid to position my elements that I have created.
    Thanks

    Hi Raymi,
    Like Ben suggested, you can vote for the feature using the link provided.  From what I understand, the product team is collecting feedback on the limitations of Live View for FG layouts and improving experience on that front. It would help if you could provide a list of limitations with the current workflow.
    Thanks,
    Preran

  • What settings need to be changed so logos (.png or .jpg) and other objects in the email (body_part_0.html or body_part_1.vcf) appear in the email in lieu of att

    We have several computers that receive email via Thunderbird. Two individuals received that exact same email. On one of the emails, the attachments are shown correctly (PDF file and a ZIP file). On the other computer, the attachments are also shown but any company logos (.png or .jpg) and other objects in the email (body_part_0.html or body_part_1.vcf) do not appear correctly in the body of the email but appear at the bottom of the email as attachments. I can send PDF files of these (2) different emails if it would be helpful.

    Matt: Thanks for the quick reply... both computers have the identical antivirus software package. I'm thinking that there has to be something in the configuration of Thunderbird that is slightly different that is giving the different results.

  • I downloaded firefox 6, and restarted computer, but the message under the search window says I don't have the latest firefox. I tried twice. thank you

    I downloaded Firefox 6 and restarted computer, but the message under the search window says I don't have the latest Firefox. I tried twice. Thank you.

    I have a similar problem; but I think the cause of the "already running" message is that my computer crashed.
    I rebooted before I learned to look for the parent lock file, but even when I knew to look for it, I found my original profile folder to be empty.
    So I created another profile folder, and FF works, but I cannot access my old profile folder. When I open the location where it should be, nothing's there. But if I go to profile manager, I see my original profile is still there (and it has a location, it's where it should be - and where it's invisible, but even if I type in this location, nothing comes up).
    I tried making all folders visible (I run Windows 7), but this did not make my old profile visible.
    I want to find it because of the bookmarks I bookmarked recently.

Maybe you are looking for

  • Project runs Ok in debug mode but not in release mode

    I have an application developed with VC++ 6.0 and measurement studio. The application controls SCXI-1161/1166 relay boards to connect the UUT. The application runs ok in debug mode, but in release mode the application can't drive the relay boards. I

  • Using SEARCH HELP exit in dependency of other parameters from my dynpro.

    Hello experts, how can I access the values of input fields (parameters or select-options) from my dynpro? I need to build a F4-help in dependencie of another field on the screen with help of the F4 - exit. I think this should be possible. If I do tes

  • Can't import Final Cut XML file into Premiere Pro CS4 MAC

    Hello,  I'm traying to import FCP Studio 2 XML file into Adobe Premiere Pro CS4for the purpose of then color correcting the project in Adobe After Effects. I followed all the rules of exporting XML files from my Final Cut Studio 2 timeline, then clos

  • ZLM 7.3 and ZCM 10.2

    Can these two products be installed onto the same machine? I am working with XEN Virtual machines and I would like to be able to install the ZCM and the ZLM onto the same machines and I would like to know if anyone has tried this, or knows if it can

  • Text is being deleted when saving to PDF

    I've been resistent to move to the upgraded Pages but did it anyways.  Recently I've noticed that everytime I save my file as a PDF it cuts out some of the text I have in a table.  It always happens when there are superscripts or subscripts used.  An