Why content of a vector element changes when new element added

in my program, i instantiate 2 Vector objects. one is TV(temporary vector), the other one is V. they all get instances of Class vElement as elements to them(of course, casted to Object first).
Class vElement only cantains an int n, an int[] array.
i create a text file: input.txt
in this text file, there are 2 rows of content:
1 2 3 1001
4 5 6 1002
at the beginning when the program runs, each row of input.txt will be read into a respective instance of vElement, that is, e.g. n = 1001, array = {1, 2, 3}.
and then the 2 instances would be casted as Objects and added to V as elements
then TV starts to get a new vElement from some methods generats 7 8 9 1003
after that, V will add TV's newly-got element as its 3rd element.
what is dramatical is that, the array of V's 1st element { {1, 2, 3} 1001 } will change to be the same as its 2nd one{{4, 5, 7} 1001 } after the 3rd element added to V from TV, yet, 1001 will not change to be 1102.
this problem has challenged and tortured me for quite some days. who can help to conquer it?
thanks a lot more!!

I had the same problem. I believe this is because Vector stores references of everything it is added into it. My problem was solved by creating a new array everytime I had to add an element to Vector.
Instead of:
My_vector.addElement(My_array)
I did:
String[ ] Prov_array = new String[My_array.length];
System.arraycopy(My_array,0,Prov_array, 0,My_array.length);
My_vector.addElement(Prov_array);
Might not be the best solution but it solved the problem.

Similar Messages

  • Why does the Date Created metadata change when images are exported?How do I stop it from changing?

    why does the Date Created metadata change when images are exported?  How do I stop it from changing? I must have a prefernce set up wrong.

    I don't know what OS you are using, or what application you are using to view the data about your exported files, but on Windows and using Windows Explorer the "Date Created" field relates only to the date that the exported file was created, i.e. if viewed immediately after export it will show the date created as being the same date. In order to view "Capture Date" in something like Explorer, you first have to ensure you have included the Metadata as Conrad outlined above, then you have to adjust the display properties of Explorer to show the "Date Taken" field. Here is an example, part of a folder I exported back on March 3rd, note the difference between that last two dates:

  • Why does the stage layout change when native menu added

    I have a program that was fine till I added a native menu to it. After adding the menu I have a space on both the left and the right of the stage. If I draw a shape at x=0, y=0 it appears about 40 pixels to the right of the window border. If I remove the menu the space still occurs what is going on?

    Adding the menu shrinks the effective size of the stage. This happens because in the app descriptor, you set the outer size of the window, not the stage size. When you add a menu, the space for the menu is created by removing space from the stage, not by increasing the height of the window.
    You see the bars around the app because you have the stage scalemode set to something other than noScale.(noScale is NOT the default.) The other scale modes attempt to keep most or all of the app in view when the app is not the same size as the stage (which happens when you add a menu to a window). The space around the edge is the result of the runtime scaling your content into the available space When you remove the menu, this space should be returned to the stage -- and does in my tests, so I can't explain why you don't see the scaling go away. Perhaps you are drawing your content based on the reduced stage size so you still have extra space after the menu is removed.
    The stage align property determines how the content is positioned on the stage when it is scaled down. The default is center which distributes space to either side when the stage is scaled horizontally, which is why the origin effectively moves away from the left side of the window. If you used the an AlignMode of top left, the origin would stay in the top left corner.
    In general, I recommend setting the stage scaleMode to noScale in an application, unless you have a specific need for one of the other scale modes. Even then, you can still scale things programmtically using logic appropriate to the situation. The other modes were designed for use in a browser where the SWF author may not have control of the stage and so must choose the least-bad compromise. In an AIR app, you have control and so don't need to make that compromise.

  • Why data in PSA doesn't  change when update rule routine is modified?

    Hello guys,
    why data in PSA is not changed after I modifiied the update rule routine. I created a infopackage which is only to PSA, but it shows me any change. If I changed this infopackage to the one which is assigned to "PSA firstly, and then to Infoobject", then I saw the changes in infoobject, but in PSA, still nothing changed.
    I can't figure out the reason. Any hint is welcome!
    Thanks in advance.
    Regards,
    Liying

    HI..
    1) PSA data is like of source system data
    2)Update rules are how you update your keyfigures to Data Tragets.
    Since you have put upto PSA that is the first data staging in BW so there wont be any change of the data even if you write routines at update rules.
    Hope it is clear
    Reg
    Ram

  • Chnages required in Config when new PSA added

    Hi All,
    I want to know the changes those are required to made in the configuration when a new PSA added to the current system.
    Thanks in advance.
    Regards,
    Sekhar.

    Hi Sekhar,
    The changes those are required in configuration when a new Personnel Sub Area added are:
    Changes in Enterprise Structure and Time Management Settings as
    Enterprise Structure: creation of new PSA
    Assignment of Pay scale structure to Enterprise structure
    Define Personnel Subarea Grouping for Primary Wage Type
    Define Groupings for the Public Holiday Calendar
    Group Personnel Subareas for the Work Schedule
    Generate Work Schedules Manually
    And let me know which modules you are having in your project, so that I can provide specific module help for you.
    Regards,
    Srinivas.

  • Why does my footer background colour change when adding a float to a DIV element?

    Bear with me as I am a student learning dreamweaver....
    I am trying to insert a series of 4 DIVs into a footer area with a black background. WHen I insert a float to constrain them to a horizontal position, the black background disappears and the body background shows through. A strip of the footer displays on top of the area where the DIVs are placed. The float works but the problem is with the background colour. It's almost as if the divs have been pushed down below the footer area. I have tried placing my cursor in several locations before inserting the float but it doesn't change anything.
    Can anyone help?

    It all depends on the code you're working with.   In the following example, I applied overflow:hidden to the <footer> element. 
    Copy & paste this code into a new, blank HTML page to see how it works.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5 Layout</title>
    <style type="text/css">
    body {
        font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif;
        background-color: #CCC;
        padding: 0;
        color: #000;
        width: 1000px;
        margin: 45px auto;
    header {width: 100%; display:block; background: #A5C9C9; min-height: 100px}
    section {width: 100%; display:block; background:#FFF; min-height: 300px}
    footer {width: 100%; display:block; background: #FF9; overflow:hidden;}
    aside {width: 22%; float:left; display:block; margin-right: 4%; background:#D8E9B6; min-height: 200px;}
    aside:last-child {margin-right:0}
    </style>
    </head>
    </body>
    <header>
    <h1>Content for header goes here</h1>
    </header>
    <section>Content for section goes here</section>
    <footer>
        <aside>aside 1</aside>
        <aside>aside 2</aside>
        <aside>aside 3</aside>
        <aside>aside 4</aside>
    </footer>
    </body>
    </html>
    Nancy O.

  • Why does my Background image color changes when I place an image ?

    Hi everyone,
       I'd like to make a presentation in InDesign. I put a background image into a different layer which I called "Background" and then I create a new layer which I called "Images" and place an image with a transparency layer. When I place this image onto the Images layer color of the image in the Background layer changes. I can not figure out why It changes its color. I'd be grateful to anyone who can help me resolve this problem ?
    Regards
    Cem

    Edit > Transparency Blend Space... and set it to match the color mode of the background image.

  • Why is the label color not changing when my file is updated?

    I would like the label color to change to white when a file has been updated/changed. Since upgrading to 10.7.2 the file color stays the same. Is there a setting I am missing that will allow the file to go back to white when updated?
    Thanks for any input...

    As far as I know, this is not standard functionality in the Mac OS.  Granted this, some third party application, or a script of something, was making this happen for you. Somehow the system update broke it. If you can figure out what software was giving you this feature, maybe you can update it or re-install it.
    charlie

  • Why does not my iCloud emailaddress change when I changed my Apple ID mail address?

    I got a new mail aqddress and changed my Apple ID. My ICloud emailadress did not change so nowe I cannot log in to iCloud, and I cannot find a way to update my iCloud address.

    You have to sign out in System Preferences (or Settings)>iCloud on all your devices On a Mac, click the 'Sign out' button; on an iOS device, click the stupidly labelled 'Delete account' - this will not delete your account from the server, only from the device.
    Then sign back in again with the new ID. Your iCloud data will disappear from your Mac/Device but will reappear when you sign back in.

  • Why does my icloud email not change when i update my appleID? and how can I change it??..so frustrating

    I updated my email because I changed my name, and now i cant sign into icloud and it still wants the password for my old email. any ideas?

    Also, it's important to follow the steps in Change your Apple ID  when changing your ID. You're supposed to sign out of all of your accounts then change the name of the Apple ID then sign in using the email address. Because find my iPhone is a thief's worst nightmare the password will only be accepted for iCloud if the account is still called that current name. So if you changed the name of the account without changing the Apple iD you'll need to change the name back (on Appleid.apple.com) then sign out in Settings>iCloud, then change the name back using the desired email (on applied.apple.com) then sign in using the preferred email in Settings>iCloud.
    Cheers

  • Color Changes when form field added

    When I add a form filed to a pdf, the color changes on the output of the pdf.
    Print out the attached pdf pages 1 and 3. Look at the green button. It is darker on the pages with the form field(p1) then on page 3. they are the same source file. It like when I add the form field, it changes the page to a CMYK color space and the images are in a RGC Color space.
    Any ideas

    Follow-up:
    One of my colleagues is working on a product feature that involves checkboxes (this is how I came across this issue in the first place). His checkboxes aren't contained within a form element whereas in my test page I described in my question when I removed the form from the page the issue didn't manifest.
    However, the page he's working on does contain other forms so I decided to modify my test page to try to replicate this scenario. I found some really odd behavior.
    If I have a form on a page but the checkboxes are not children of that form, and if I dynamically add a single INPUT element or a single TEXTAREA input, the checked values just disappear on page refresh. That's expected since the lack of a parent form should eliminate the memory of the checkbox values, right?
    Well, when I dynamically add '''both''' an INPUT element and a TEXTAREA element it goes right back to remembering '''and''' moving the checked value, but only by one step. By comparison, if the checkboxes and the dynamically added form fields are contained with a form the checked value will move by a number of steps equal to the number of dynamically added form fields.
    Strange, strange behavior I can't really decode with certainty across the entire range of possible scenarios...

  • File associations change when new packages are installed (GNOME)

    Hello!
    Imagine I set Geany to open text files. It works, I just double click the files and they open with Geany. When I install Wine/Gedit/whatever... it overwrites my file association with Geany, opening it by default with notepad.exe/gedit/whatever.
    Can someone help me?
    Thanks, acmps

    I don't know why this happens sometimes after installing or messing around with wine, but I can also confirm multiple, false entries in that associations-list.
    But I know how to get rid of it after it happened (concerning these entries in my gnome-open-dialogue):
    Delete the files which fit in ~/.local/share/applications/* or have a look at mimeapps.list which is also located there

  • BEx Analyzer (7.x): currency change when new formula created

    Hi All,
    I have a strange one.  Query is executed in BEx analyzer.  A new formula is created outside the query results window using excel functionality, and the currency changes from USD to DM. 
    Example query results: 
    Cell A1: Var 1 = $150.00
    Cell B1: Var 2 = $160.00
    Cell C1: Var 3 = $70.00
    New formula created using excel functionality:  =sum(A1+B1) displays as 310.00 DM
    The language settings have been checked for the operating system and for SAP (user data) and they appear to be correct.  Is there another setting to be checked?
    Thanks,
    Pam

    sap said it was working as designed.  suggested we look at regional settings on laptop and make a workbook template with us settings.

  • Metadata window doesn't change when new thumb is selected

    Since recent update I have the following problem several times a day:
    I add metadata (in split window) to a few pics. Click on another thumbnail to edit its metadata and the metadata window (left of screen) doesn't show info for the newly-clicked-on pic. It continues to show info from previous pic. Can't change that window regardless of the view or how many other pics I click on.
    Only solution I've found is to close and reopen. This happened four times yesterday, and again, within 10 minutes of starting to edit today.
    I looked into plists for Aperture (home>library>app support), but there are a lot of them and I'm not sure which might be causing the problem—or if any are.
    Thanks for the help.

    Here is an example. Click on the button and you see the change.
    Thanks
    -D

  • Why does my ipod touch keep changing to new passwords automatically on update iOS 8.2.1?

    sd

    Passwords for what specifically?
    Can you provided details of what you are doing and what message concerning passwords you are getting.

Maybe you are looking for

  • Leopard and Adobe Photoshop CS2 problems...

    I've been reading the posts about Leopard and CS2 problems and have to say that I'm confused. A great many of you have had issues from the very beginning as soon as you upgraded to Leopard. I did not. I use a VERY basic set-up without third party plu

  • Web Services Connection Timeout

    Hello All, I have a web services client that runs in Tomcat. When making a web service call, I am getting the following exception: HTTP transport error: java.net.ConnectException: A remote host did not respond within the timeout period.      at com.s

  • What is xmx - and how do I change the settings

    I get this error: "Several Java Virtual Machines running in the same process caused an error". Some brains inhere wrote about this error, and solution should be: "adjust his -Xmx setting down from 512M to 256M." How on earth do I do that? I don't eve

  • My iPhone 4s calendar doesn't have an add " " button so I'm unable to create calendar items- Any idea how to fix this?

    My iPhone 4s calendar doesn't have an add "+" button so I'm unable to create calendar items- Any idea how to fix this?

  • Crashing when loading songs

    7.2.1 I had one song open, and asked it to open another while keeping the first open (admittedly they're both big songs, lots of VSL EXS's) and it hung while opening the 2nd song. I Force Quit, and now it won't open either song, gets so far thru the