New to Java, new to array(compacting ,removing etc..)

hey everybody,
bear with me im new to JAVA, currently taking my first course in Programming, and one of the assignments is on arrays. my question is i need to compact the array so if an element is removed then i would have to shift each one down so it doesnt waste memory and also have the array packed which means i have to keep all valid elements in the beginning and nulls at the end any suggestions or examples?. i didnt write any part of the code yet so im not sure if my description helps...
BTW any suggestions as to where i can get practice in Java Programming? my hws sorta help but its not enough practice, and this is all new to me so any suggestions either websites or books?

thanks for the replies and the link, i think i sorta got an idea how to shift
well the thing with the array is that if the user inputs a number that is the same as an element in the array i need to remove it, well i guess you can say i have a problem starting the code does any one have a simple example on arrays? and im still confused about creating temps also, can anyone explain in what situation do we have to create temp variables? from my understanding is it only when you wanna change the size of the array? thanks in advance

Similar Messages

  • Can't store new target Array index out of range: 1 - SLD Configuration

    Hello ,
    Issue is regarding SLD configuration , We have ABAP + Java Addin on Suse Linux x86 ( 64 bit ) with Oracle 9.x .
    Java instalaltion competed succesfully , J2EE is up and runnung while configuring SLD , Data Supplier Bridge - Configure the data supplier bridge - Update SLDs
    As I set Update local SLD (sld/active) to true it gives error : Can't store new target Array index out of range: 1
    ( Error recorded in default.trace ,
    #1.5#001635052D79005D000000010000393A00041904004A592B#1153404882278#com.sap.engine.library.monitor.mapping.ccms.Trace##com.sap.engine.library.monitor.mapping.ccms.Trace######87587b2017f911dbc661001635052d79#SAPEngine_System_Thread[impl:5]_82##0#0#Error##Plain###RegisterNode</Services/Web Services/Requests Number/sap.com/com.sap.engine.heartbeat/GRMGWSTest/CurrentClient>: com.sap.mona.api.JMonException: com.sap.mona.api.JMonAPIException: Internal error in tree structure#
    #1.5#001635052D790049000000060000393A000419040226E9F1#1153404913510#com.sap.lcr.sagent.BuilderDirector#sap.com/com.sap.lcr#com.sap.lcr.sagent.BuilderDirector#J2EE_ADMIN#317####29009b1017fa11db96bd001635052d79#SAPEngine_Application_Thread[impl:3]_14##0#0#Error#1#/Applications/SLD#Plain###Can't access http store#
    #1.5#001635052D790049000000070000393A000419040226EA90#1153404913511#com.sap.lcr.sagent.BuilderDirector#sap.com/com.sap.lcr#com.sap.lcr.sagent.BuilderDirector#J2EE_ADMIN#317####29009b1017fa11db96bd001635052d79#SAPEngine_Application_Thread[impl:3]_14##0#0#Error##Plain###Thrown:
    com.sap.lcr.api.cimclient.LcrException: java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 1
    I have already through updated Component Repository – SAP Note : 669669 . 
    Regards ,
    Santosh

    Hi,
    I am having exactly the same issue. Would you please advise what the solution was?
    Thanks,
    Murad.

  • Yet another case of new type[array] and parametrized type

    I suppose this is an often asked question, to which I seem not to be able to find a simple answer. I know of the "incompatibility" of arrays and generics, and yet in such a seemingly simple case I run into a mystery, or a compiler bug. Look at this warning:
    Set<Integer>  C[];
    foo/bar/some.java:1148: warning: [unchecked] unchecked conversion
    found   : java.util.HashSet[]
    required: java.util.Set<java.lang.Integer>[]
                    C=new HashSet[H-L+1];So far so good, but precisely this *"Set<type>[]"* does not exists, does it? When I try to add a parametrized type to this new statement, compiler says:
    Set<Integer>  C[];
    foo/bar/some.java:1148: generic array creation
                    C=new HashSet<Integer>[H-L+1];
                      ^
    1 errorIn a regular case we can easy deal with the "unchecked" warnings, e.g. Effective Java 2nd Ed, Item 24 discusses this, but all this seem to be ignoring this case. When generic array creation is not permitted, than why this warning stating that *"java.type<typeparam>[] required"* appear, and how to resolve this for safety and correctness? Of course, I can still ignore the warning and do a few instanceof checks and casts, like before, but I am really curious how to transfer this into the new paradigm.
    As much generics improve and help in many cases, I regret their arcane complexity. To paraphrase C.A.R. Hoare, the Java language itself becomes now the problem, not its solution.
    Thomas

    I wonder if we have someplace recent measure just an array stack against a current implementation of a set in Java? In JDK1.4 I remember array was several times faster, 350% faster if my memory serves me, and I do have the classic "inner loop" operation, very repetitive. I can live with the warning, what's the problem?
    Of course all this are considerations fully aside of the issue at hand, that the JDK1.6 compiler prints a nonsense warning message that a parametrized array is expected, what is in fact illegal in current implementation of generics. Which is in my eyes severely faulty, but that would be yet another assault on the Braha Ivory Tower, wouldn't it?
    Thomas

  • Migrate zpools to new storage array

    I am in the process of migrating to a new EMC storage array. I used EMC SRDF to copy all tracks from the current disks to the new disks, so that all new disks look identical except for the actual device path since the WWN is different on the new array. I was hoping I could simply unmask/unmap the old SAN, mask and map the new SAN, and ZFS would be able to import the pools from the new SAN (like you can with veritas), but I didn't take into consideration that the device paths/names would be different and ZFS wouldn't like it. Is there any way to get solaris to see the new ZFS pools that now exist on the the new storage array so that I don't have to mirror and then remove the disks from the pool and pretty much wipeout all of the sync work I've already done with the EMC software?
    Hopefully this makes sense, but please let me know if I need to explain further.

    No issue, works as expected, I just didn't split the synchronization between the old and new devices, so the new disks were still write disabled in EMC land. Once I split the sync, everything imported without a hitch, so it was my stupid mistake.

  • My new Dell PC running Windows 8 does not recognize my iPad or iPhone. Worked OK for iPhone for months but would not work for new iPad.  I removed /relaoded iTunes and now it won't recognize either iPad or iPhone.

    My new Dell PC running Windows 8 does not recognize my iPad or iPhone. Worked OK for iPhone for months but would not work for new iPad.  I removed /relaoded iTunes and now it won't recognize either iPad or iPhone. Got any suggestions?

    Hi there Lizabethfromaz,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/ts1538
    -Griff W. 

  • In previous version F6 can Edit url but new version can't it have new hot key or remove it?

    in previous version F6 can Edit url but new version can't it have new hot key or remove it??

    F6 focuses the first selectable element.<br />
    If "Tabs on Top" is selected then the active tab is selectable, so the location bar is not selected.<br />
    Press F6 to set focus on the Tab bar and press the Tab key until the location bar gets focus.
    To get the 3.6 behavior uncheck "Firefox button > options > [] Tabs on Top" or use Alt + D or Ctrl + L

  • K8N DIAMOND: New Raid array and old HD... I'm going crazy!!! Please

    Hi guys
    First, sorry for my poor english...
    My problem is:
    I bought two Raptor 36 Gb for my new raid array.
    I have my old HD Hitachi 250 Gb connected on sata 1.
    I connected my two raptor, on sata 3 and 4, I enabled all sata port and raid config for ports 3 and 4.
    I restart PC, typed F10 and set a stripe array with two raptor. All run ok...
    Restarted and boot with my copy of WinXP with SP2 and NF4 raid drivers.
    Installation found my array and my Hitachi;
    Hitachi with 4 partitions; C (os), D (driver), E (films), F (music)
    I create one partitions on my raid array, and it takes I: letter... So I formatted and start to copy os...
    Errors occurs when, restarting pc and resetting the boot to Hard disk (the order of booting is 1 - nvidia array, 2 - hitachi 250 gb), just before loading installation, It shows a black screen with an error: "there is an error in your hard disk bla bla bla.. try to control your connection or connect to windows help....bla bla..."
    The Raid array works properly, infact I try to disconnect my Hitachi from sata port 1 and all installation works (I'm writing from Win xp on the raid array).
    I tried to connect the hitachi on port 1 of silicon image controller.... same error..!!
    I'm desperate... I have all my life on my hitachi...
    I think that there's  a sort of conflict in drive letter assignement... I cant find a solution ..
    PLEASE HELP ME!!!

    Glad it worked, I had a feeling it would. 
    Quote
    One question for you.. on G: partition, there's a directory called "Windows", do you suggest me to format this partition??
    You can format it if you want to free up space, but unless you moved things around the My documents folder and everything in it is on that partition, along with anything you might of had on the old desktop during that Windows install.  You might have something you want there, I usually leave mine for a few month, and figure out if I have everything I need.
    Quote
    What I  have to do, if I need to reinstall WIn XP on first partition of raptor array??
    Things should be fine now as Windows marked the Hitachi drive as G. You should be able to reinstall without issue. But if you have a lot of sensitive info on the Hitachi, I would always disconnect the Hitachi if doing a fresh install.  Once windows is done installing, hook it back up.  But next time you shouldn't have to reconfigure NVRAID after disconnecting and reconnecting.
     

  • Adding new RAID arrays on TD200

    Hi,
    We have a TD200 server with MR10i ServeRAID card installed and a single RAID 1 array of 2x 500Gb 3.5" drives. We need to upgrade and are trying to decide the best path.
    We have two free 3.5" slots so could we create a new RAID1 array on the same backplane without needing to change the internal cabling or disturb the existing array?
    Alternatively all eight 2.5" drive slots are free. We could create a RAID 5 array on there, is that backplane likely to have been connected up to the MR10i? Is the MR10i card happy enough connecting to two different backplanes? Our server would require to be physically moved and switched off to get good access to the side panel, so I'm trying to get an idea before taking that step!
    Our usual supplier only seems to stock IBM hotswap drives, I read somewhere else on the forums that to fit in with our existing server warranty we'd need to get Lenovo drives, is this true? Finally, if we required cabling for connecting to the 2.5" drive backplane do you have suggestions for UK based suppliers, plus what the cable codes/details are?
    Lots of questions! If you can help on any of them that would be great thanks.
    Kind regards,
    Stephen.
    Solved!
    Go to Solution.

    This all depends on how many ports on the RAID card.  If there is more than one, you should be able to create more than one array.

  • Hi i forgot my code to my ipod touch and will certainly not on it. it is, connect to itunes, I've done it. but will still on. I can get help to get a new code? or remove the code ..?

    hi i forgot my code to my ipod touch and will certainly not on it. it is, connect to itunes, I've done it. but will still on. I can get help to get a new code? or remove the code ..?

    Place the iPod in Recovery mode and then restore the iPod via iTunes on your computer.

  • Does upgrading to new pages on iPad remove older version of pages

    Does upgrading to new pages on iPad remove older version of pages. In other words, after upgrading will I be able to open older Pages documents on the iPad?

    I took a while to figure this out after I got into the same mess. The new iWorks is a very bad downgrade. I have deleted Pages 5 from my Mac and gone back to Pages 4.3 (it is still there and was not removed when you updated to Pages 5.)
    I then deleted Pages 2 from my iPad and from iTunes.
    I used TIme Machine to go back to ~/Music/iTunes/Mobile Applications in September and found "Pages 1.7.2.ipa" and brought it forward to my desktop. I then droped it into the iTunes icon in the Dock and it reinstalled.
    Hope this works for you.
    Apple can now take as long as they need to correct all the mistakes they made with the current version of iWorks - I will not be upgrading again until they do.
    Apple - Are you listening?

  • Outlook Profile Not Updated to New CAS Array After Mailbox Move Between Sites

    I am working on a large mailbox migration from one AD site to another. 
    Exchange version at both sites:Exchange 2010 SP2
    Two Mailbox Servers: MBX01 in site A / MBX02 in site B
    (There is a DAG but keeping this simple)
    Two CAS Arrays: CASA.domain.com / CASB.domain.com
    The RPCClientAccessServer property is set accordingly.  Where MBX01 is set to CASA.domain.com and MBX02 is set to CASB.domain.com
    Clients:Outlook 2010 SP1
    Scenario: I successfully move a mailbox from Site A to Site B.  The Outlook client does not automatically update its server settings to point to the new cas array (CASB.domain.com) and continues to connect to the old CAS server (CASA.domain.com).
    I have seen a few articles regarding this pointing to workarounds such as:
    - repairing the outlook profile on the client
    - delete the existing outlook profile
    - run a script to update the prf file (re-cache's email at the client)
    I am interested in knowing if anyone else has experienced this, what their solution was for a large migration and if any roll-ups or service packs have possibly fixed this problem.
    I would also like to know if you have seen this affect ActiveSync devices.  I am getting mixed results in my tests and thought it may be contributed toward different device types, mobile os versions, etc...
    I have posted this to the Outlook forum as well, just wasn't sure where to start.
    Thanks.
    Mike

    Hi,
    Firstly, I’d like to say, in Exchange 2010 and prior to SP2 CU3 version,
    when we move mailboxes between AD sites, users will not receive any notice about restarting Outlook and their RPC endpoint won’t update to reflect the RPC Client Access Server array associated with the mailbox database in the AD site where the mailbox now resides.
    Depending on repairing or recreating profile, we can force Outlook to use the new RPC endpoint.
    If you have any question, please feel free to let me know.
    Thanks,
    Angela Shi
    TechNet Community Support

  • New SAN array not all paths login until reboot

    We have a senerio with some of our UCS domains.  when we add a new storage array some paths will login to the array but not all will login until we reboot a host.  We have 4 UCS domains 6140x, 6248 and 2 x 6296.  the older 6140 seems to always login and have no issues the newer seems to only login a single path and sometimes none until a reboot of the blades occurs. the FI up link to Brocade 5300 FC switches.  This does not appear Firmware related as the newer 6296 are on 2.2.3b and the other are on 2.1.3e until next main window.  I am thinking there is some issues with the upstream brocades and RSCN passing toe th newer FI .  Any thoughts and direction as i really don't want to spend the next month rebooting hosts.

    Hi ehphillipsme,
    Since you are using multiple domains have you verified that you don't have duplicate wwpns between your UCS domains?

  • HT1369 I tried to update my phone to the new system but i removed it from my cpmputer and now its stuck on the connect USB to itunes screen.....

    I tried to update my phone to the new system but i removed it from my cpmputer and now its stuck on the connect USB to itunes screen.....HELP

    Hello the_generator2003,
    It sounds like after having disconnected the iPhone physically during the update process, the phone appears to be stuck in recovery mode. If you have followed the onscreen image, and reconnected the device to your computer, then I would start by resetting the phone and trying again:
    From: Turn your iOS device off and on (restart) and reset
              http://support.apple.com/kb/ht1430
    If the issue is not resolved, then try putting the unit into recovery mode again with this article:
    iOS: Unable to update or restore
    http://support.apple.com/kb/HT1808
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • When I click to open anything I get a box saying open link in new window, open link in new tab, download linked file etc.  When I go to close anything I get hide toolbar, customize toolbar.  It takes  3-5 clicks and it will finally close.

    When I click to open anything I get a box saying open link in new window, open link in new tab, download linked file etc.  When I go to close anything I get hide toolbar, customize toolbar.  It takes  3-5 clicks and it will finally close.

    In Firefox Options / Privacy be sure "Remember download history" is checked. To see all of the options on that panel, "Firefox will" must be set to "Use custom settings for history".
    To find your OS information, on your Windows desktop, right-click the My Computer icon, choose Properties, under System on that small window is info about your OS.
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

  • Using a function and array to remove stage instances

    I'm trying to figure out the best way to handle this.
    I have an array of items I want to be looked through and removed if a specific function is running and if the stage contains them.
    removalArray = [axScene, bridgeScene];
    public function Removal(event:Event) {
                trace("cheese");
                for (var i:uint = 0; i>removalArray.length; i++) {
                    if (stage.contains(removalArray[i])) {
                        removeChild(removalArray[i]);
                        removeEventListener(Event.ENTER_FRAME, Removal);
                        addEventListener(Event.ENTER_FRAME, CampScene);
                    } else {
                        removeEventListener(Event.ENTER_FRAME, Removal);
                        addEventListener(Event.ENTER_FRAME, CampScene);/**/
    addEventListener(Event.ENTER_FRAME, Removal);
    I'm able to get trace("cheese"); to work at its current position, but the function does not seem to like my "for" and "if" statements because putting trace("cheese") amongst them does not work.
    As always, help is appreciated, and let me know if you need more info.
    EDIT: Perhaps I should also note I am able to get
    if (stage.contains(axScene)) {
                    removeChild(axScene);
                    } else if (stage.contains(bridgeScene)) {
                        removeChild(bridgeScene);
                        } else {
                            null;
    to work correctly in that function.
    EDIT2: Would this have something to do with addChild only being able to remove one instance at a time? I can't imagine that's it since this suppose to be run through a loop.

    You appear to have an unhealthy obsession with using the ENTER_FRAME event. 
    I'm sure you're right, but realize that I'm learning by the seat of my pants and am not great with logic and stuff that doesn't happen chronological. (I'm 26, and graduated with a degree in graphic design.) If I find something that works I'm going to keep using that until I find a better way, and thus far ENTER_FRAME has been all I've had. (I can find tons of AS3 information online, but a lot of it is forum posts seems to be lacking useful context for my purposes.)
    For what it's worth (if you remember another post I did that had a ton of event listeners), I've started using more booleans and gotten rid of a lot of listeners adding and removing.
    What you might try doing instead of creating all manners of them is to have just one and within that one you manage your objects using conditionals.
    So something like this?
    if (campSceneOnStage == true) {
         addChild(campScene)
         } else if (campSceneOnStage == false) {
              removeChild(campScene);
    EDIT: Although this would keep adding a campScene instance, wouldn't it?
    EDIT2: Could I write something like this, have one constant event listener (addEventListener(Event.ENTER_FRAME, Scenes)...
    public function Scenes(event:Event) {
                if (campSceneOn == true) {
                    addChild(campScene);
                    if (stage.contains(campScene)) {
    and use a line to tell the function to temporarily stop listening if campSceneOn = true and campScene is on the stage?
    Would "null" work?
    Also, is there an equivalent to "stage.contains" that looks to see if the stage does not contain?
    That ENTER_FRAME listener is being removed as fast as it was added, whether or not there is something in the array to remove.
    So the even though the intention is to only have the removeEventListener only occur if something is found in the array to remove, the script "skips over" that and removes the event listener even if it doesn't "use" the for loop or if statements?

Maybe you are looking for