Java: How can one check for index out of bound?

simple while loop
while (something [ i ] ==k)
i+=1;
document.write(save [ i ]);
Thanks everyone :o)
Edited by: bvc on Sep 21, 2007 3:33 PM
Edited by: bvc on Sep 21, 2007 3:34 PM
Edited by: bvc on Sep 21, 2007 3:34 PM

you need to make sure that i is always less than the length of the array, so in your while loop, you should have that as one of your conditions
while( i < something.length && something[i] == k )
  //blah blah
}Also, please encapsulate your code in code tags.

Similar Messages

  • How can I check for VSearch trojan?

    how can I check for VSearch trojan? And then remove it if found?

    Helpful Links Regarding Malware Problems
    If you are having an immediate problem with ads popping up see The Safe Mac » Adware Removal Guide, AdwareMedic, or Remove unwanted adware that displays pop-up ads and graphics on your Mac - Apple Support.
    Open Safari, select Preferences from the Safari menu. Click on Extensions icon in the toolbar. Disable all Extensions. If this stops your problem, then re-enable them one by one until the problem returns. Now remove that extension as it is causing the problem.

  • How can one search for a filename anywhere on the Mac?

    How can one search for a filename anywhere or everywhere on the Mac?

    You can configure Spotlight so it will also search in system files or you can download and use EasyFind 4.9.3 that doesn't require special configuration.
    Get Spotlight to search system files (and more)
    Enter the search term in the Finder window's search field.
    Click the [+] button in the search bar to add a search option.
    In the first drop down menu choose Other.
    Choose “System Files” from the list that pops up (and check the box to place in drop down menu to avoid this step later,) click on the OK button.
    Now back in the Finder choose Include from the second drop down menu.

  • How does one check for Updates...

    How does one check for Updates when :
    Registration
    Deactivation
    Updates
    Menu items are greyed out! ?

    Actually, it's a timing issue. Those items are greyed out for a couple of minutes after PPro starts. A little patience and they become available. ;)
    Cheers
    Eddie
    PremiereProPedia   (
    RSS feed)
    - Over 300 frequently answered questions
    - Over 250 free tutorials
    - Maintained by editors like
    you
    Forum FAQ

  • How can I check for the existence of an XML file in Illustrator Javascript??

    I'm writing a Javascript to run at startup. I want to check for the existence of XML files and process them, if they are available. How can I check for their existence?

    Your first line just sets a variable to a string value… getFiles() is a method of Folder… so
    var InputXMLDir = Folder( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/" );
    Not a PC user so I can't remember if the colon is OK…? As you appear to know the file name why bother with a folder get files anyhow you could just check if the file exists then do some thing…
    alert( File( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/brackets_men_web.xml" ).exists );

  • I just buy iPhone4 first hand on Jan 07,2013 but the warranty expire date How can i check for the date of production?

    I was bought iPhone4 16 GB on Jan 07, 2013 from online shop from Laos they told me that this iPhone from Apple in Hongkong (first hand) but I check for the warranty is already expire date. What should we do? I want to know about my iPhone4 first hand or second hand. How can i check?

    This will show you warranty status and give you an idea
    of when originally sold:
    https://selfsolve.apple.com/agreementWarrantyDynamic.do

  • How can I check for 'undefined'?

    Hi,
    I am creating a custom MP3 player where audio playback is
    started by clicking on the title of the audio, but I also want to
    be able to start play abck from the Play/Pause button. In order to
    implement this dual approach, I am thinking of checking if a sound
    has been loaded (with 'mySound.loadSound("path to sound") already
    by the my titleButton.
    I am thinking of doing this by checking the
    'mySound.position' as that would be 'undefined' if there was no
    sound loaded.
    But how can I check it for being 'undefined', what woud be
    the syntax? Itexpects a number so I tried -1, but that didn't work.
    Or is there a better way?
    Thx,
    Nik
    have a Play/Pause button and for it in order to

    Found the answer.
    The code is of course:
    etc. //
    if (mySound.position == undefined) {
    // etc.
    I had a erroe else where.
    NIk

  • Technology P2P with JAVA (How can i do for implement this tech with JAVA B)

    Thanks for read this message,,, I will glad with you if you can help me...
    I would like desing, make, build, a point to point aplication with JAVA Builder, I have been reading about sockets but its not enought,,,,,,
    can you help me????
    Thanks

    Well , thanxs for take attention,,,
    I need some information about Point to Point tech because I would like to make an aplication with JAVA Builder...
    First step is to know how works the point to point...could you give me some links?
    Second step is to know how can I do for implement this tech?
    Third step is to know Is Java Builder the most indicate languaje for this aplication?
    Fourth step is - if Java Buider is the indicate tool, What have to know for make the aplication?
    Well,,I dont speak english very well but is the best that i can do?
    BYE

  • How can I check for directory creation?

    Hi,
    I want to check whether I can create a directory at a particular location.
    Let's say at c:\windows, can create a directory called c:\windows\mydir. But I won't be knowing the parent location (i.e., c:\windows here) at compile time.
    And I would also like to check for creating a directory like c:\windows\mydir1\mydir2 (mydir1 may not even exist).
    What I was doing was, I created the file object for my new directory (i.e., mydir here) and used the canWrite() method on the parent directory. But this method worked only when the parent directory existed. But how can check for a directory path like c:\windows\mydir1\mydir2 where I have to create both mydir1 for mydir2.
    Is there any other methods that I can use to perform this kind of a check.
    Thank you

    I finally figured out a workaround, but i don't know whether this is a good way of checking. :)
    import java.io.File;
    public class TryMKDIRs {
         public static void main(String[] args) {
              File file = new File("c:\\mydir1\\mydir2\\mydir3");
              boolean canICreateDir = false;
              if(false == (canICreateDir = file.canWrite())) {
                   System.out.println(file.getAbsoluteFile() + " cannot be created.");
                   File fileparent = file.getParentFile();
                   while(fileparent != null && (canICreateDir = fileparent.canWrite()) == false) {
                        System.out.println(fileparent.getAbsoluteFile() + " cannot be created.");
                        fileparent = fileparent.getParentFile();
              if(canICreateDir) {
                   file.mkdirs();
                   System.out.println("Directory can be created. . .");
    }

  • Can I exit from paintComponent?  ...or... how can I check for invalid data?

    I'm writing a calendar applet for a programming class and I've nearly completed it but I'm stuck at checking for valid data.
    What seems to be happening is that paintComponent() is being called before actionPerformed.
    In actionPerformed (when they click the button), it checks to make sure they entered a valid month (1 to 12). If the didn't it dispalys a message, but if they did it calls repaint().
    But even if repaint() isn't called, Java still seems to call it before actionPerformed and I get exceptions.
    So I tried checking inside of paintComponent() by using a simple if(...) return; but that doesn't seem to do anything... it just keeps going through with the method.
    So -- Once the user presses my button I want to make sure the data is valid before repainting the screen. How can I do this?

    I validate it in actionPerformed which is called by
    the action listener... that is what you meant right?
    The problem is that it seems paintComponent() is being
    called before I can validate the data with
    actionPerformed(). I need to stop paintComponent()
    from always being calledMVC. (Model, View, Controller)
    Initially the internal value of the data (the model) should be valid (or null with a check in the paintComponent method)
    paintComponent (the view part) shows the state of the valid data.
    You press the button.
    actionPerformed is called (the controller).
    It checks the value and, if valid, writes it to the data (model), then updates the view.
    At no point will the view have to render invalid data, because the model is only updated after actionPerformed checks the value.
    The pattern may be applied with different classes performing the three roles, or different methods in the same class (sometimes it's easier that way for simple cases).
    Pete

  • HT1752 how can I check for SpyBots and other invasion things on my computer

    I am beginning to have odd things happen to my computer.  Someone told me to check for SpyBots, but I don't know how.  I participate on Blog Talk Radio, and was informed they use these spybot things.  How do I find out if there are invasive things like this affecting my computer?
    In the last 2 days I've had two windows pop up saying I needed to restart the computer.  This has never happened before.  Any help anyone?

    Forget about the advise on the spybots. That person doesn't have the foggiest idea what is going on.
    You are having kernel panics. The most likely casue for kernel panics is hardware problems usually RAM that has gone bad.
    Go to http://thexlab.com/faqs/kernelpanics.html for a good procedure on how to find out what is causing the kernel panics.
    Allan

  • How can I check for a Virus?

    Hello, I tried to use my internet banking the other day on my MacBook Pro but for some reason my password wasn't working. I phoned my bank and they informed me that it had been blocked due to a security threat they'd picked up. They suspect there is some sort of Trojan on my computer and someone is trying to gain my details. They said they would unblock my banking access once I had done a virus check on my computer.
    Also- the other day I got an email saying that someone from the Ukraine had tried to access my emails. I'm not sure if this is related or not... but now i'm afraid there could be something on my computer! Is there a scan I can do? And also is there anyway I can check for a keystroke program as well? My bank mentioned this may have been used (although I am the only person with access to my laptop)
    Thanks for your help! PS - My mac is 10.6.8

    It is extremely unlikely that you have any kind of malware on your computer causing this problem. This is probably a canned reply from the bank, and it assumes you're using Windows.
    Most likely, someone had been trying to remotely hack into your bank account. This may have been the result of someone gaining access to your e-mail account, which would provide them with a rich source of information about all your other online accounts, including your bank account. You should immediately change your e-mail password. You should also change the password for any accounts that use the same password as your e-mail account, or any accounts that are associated with the e-mail account. Make sure you're not using the same password for more than one online account... use a password manager like 1Password to keep track of them all if necessary.
    In addition, you will need to closely examine any security questions associated with your various accounts. Your e-mail may provide a lot of information that could allow an attacker to guess the answers to those questions on your other accounts, thus bypassing the password. Change your security questions to nonsensical words or phrases, unrelated to the question, and keep a log of those answers in a secure place, such as in a secure note in your keychain (using the Keychain Access app) or in your password manager.

  • How can I check for keylogger and other malicious software on a used Mac

    I purchased a used iMAC (Late 2012 21.5") and it has OSX 10.9.4.
    How can I ensure that it is clean and doesn't have any password or key logging or other malicious software installed in it ?
    I basically want to ensure I have a clean iMac at the start and not have to worry about security.
    Thanks

    The first thing to do with a second-hand computer is to erase the internal drive and install a clean copy of OS X. You—not the original owner—must do that. Changes made by Apple over the years have made this seemingly straightforward task very complex.
    How you go about it depends on the model, and on whether you already own another Mac. If you're not sure of the model, enter the serial number on this page. Then find the model on this page to see what OS version was originally installed.
    It's unsafe, and may be unlawful, to use a computer with software installed by a previous owner.
    1. If you don't own another Mac
    a. If the machine shipped with OS X 10.4 or 10.5, you need a boxed and shrink-wrapped retail Snow Leopard (OS X 10.6) installation disc from the Apple Store or a reputable reseller—not from eBay or anything of the kind. If the machine is very old and has less than 1 GB of memory, you'll need to add more in order to install 10.6. Preferably, install as much memory as it can take, according to the technical specifications.
    b. If the machine shipped with OS X 10.6, you need the installation media that came with it: gray installation discs, or a USB flash drive for a MacBook Air. You should have received those media from the original owner, but if you didn't, order replacements from Apple. A retail disc, or the gray discs from another model, will not work.
    To start up from an optical disc or a flash drive, insert it, then restart the computer and hold down the C key at the startup chime. Release the key when you see the gray Apple logo on the screen.
    c. If the machine shipped with OS X 10.7 or later, you don't need media. It should start up in Internet Recovery mode when you hold down the key combination option-command-R at the startup chime. Release the keys when you see a spinning globe.
    d. Some models shipped with OS X 10.6 and received a firmware update after 10.7 was released, enabling them to use Internet Recovery. If you have one of those models, you may not be able to reinstall 10.6 even from the original discs, and Internet Recovery may not work either without the original owner's Apple ID. In that case, contact Apple Support, or take the machine to an Apple Store or another authorized service provider to have the OS installed.
    2. If you do own another Mac
    If you already own another Mac that was upgraded in the App Store to the version of OS X that you want to install, and if the new Mac is compatible with it, then you can install it. Use Recovery Disk Assistant to prepare a USB device, then start up the new Mac from it by holding down the C key at the startup chime. Alternatively, if you have a Time Machine backup of OS X 10.7.3 or later on an external hard drive (not a Time Capsule or other network device), you can start from that by holding down the option key and selecting it from the row of icons that appears. Note that if your other Mac was never upgraded in the App Store, you can't use this method.
    3. Partition and install OS X
    a. If you see a lock screen when trying to start up from installation media or in Recovery mode, then a firmware password was set by the previous owner, or the machine was remotely locked via iCloud. You'll either have to contact the owner or take the machine to an Apple Store or another service provider to be unlocked. You may be asked for proof of ownership.
    b. Launch Disk Utility and select the icon of the internal drive—not any of the volume icons nested beneath it. In the  Partition tab, select the default options: a GUID partition table with one data volume in Mac OS Extended (Journaled) format. This operation will permanently remove all existing data on the drive.
    c. An unusual problem may arise if all the following conditions apply:
              OS X 10.7 or later was installed by the previous owner
              The startup volume was encrypted with FileVault
              You're booted in Recovery mode (that is, not from a 10.6 installation disc)
    In that case, you won't be able to unlock the volume or partition the drive without the FileVault password. Ask for guidance or see this discussion.
    d. After partitioning, quit Disk Utility and run the OS X Installer. If you're installing a version of OS X acquired from the App Store, you will need the Apple ID and password that you used. When the installation is done, the system will automatically restart into the Setup Assistant, which will prompt you to transfer the data from another Mac, its backups, or from a Windows computer. If you have any data to transfer, this is usually the best time to do it.
    e. Run Software Update and install all available system updates from Apple. To upgrade to a major version of OS X newer than 10.6, get it from the Mac App Store. Note that you can't keep an upgraded version that was installed by the original owner. He or she can't legally transfer it to you, and without the Apple ID you won't be able to update it in Software Update or reinstall, if that becomes necessary. The same goes for any App Store products that the previous owner installed—you have to repurchase them.
    4. Other issues
    a. If the original owner "accepted" the bundled iLife applications (iPhoto, iMovie, and Garage Band) in the App Store so that he or she could update them, then they're irrevocably linked to that Apple ID and you won't be able to download them without buying them. Reportedly, Mac App Store Customer Service has sometimes issued redemption codes for these apps to second owners who asked.
    b. If the previous owner didn't deauthorize the computer in the iTunes Store under his Apple ID, you wont be able to  authorize it immediately under your ID. In that case, you'll either have to wait up to 90 days or contact iTunes Support.
    c. When trying to create a new iCloud account, you might get a failure message: "Account limit reached." Apple imposes a lifetime limit of three iCloud account setups per device. Erasing the device does not reset the limit. You can still use an iCloud account that was created on another device, but you won't be able to create a new one. Contact iCloud Support for more information. The setup limit doesn't apply to Apple ID accounts used for other services, such as the iTunes and Mac App Stores, or iMessage. You can create as many of those accounts as you like.

  • How can I check for duplicates in Apple Photos?

    Can't use my existing apps to check for duplicates in Apple Photos as they only work with iPhoto folders. Any ideas how I can get around this gap?
    OS X 10.10.3

    Duplicate Annihilator for Photos:  http://brattoo.com/propaganda/#photos
    PowerPhotos: http://www.fatcatsoftware.com/powerphotos/

  • How does one check for view changes to avoid unnecessary reprovision?

    I have a couple of ActiveSync resources that I setup custom userforms and workflows for to sync up only a couple of attributes from each one. With ActiveSync whenever a user account is modified it processes the modified account no matter which attributes were actually modified. For example, if I want to sync the email attribute from an Active Directory resource the ActiveSync workflow receives modification events for all changes to Active Directory accounts, not just email. With my simple workflow what often happens is that I reprovision the accounts even when no changes are made. The downside of this is that the Lighthouse account is marked as being modifed by the ActiveSync proxy user even though no real changes were made and extraneous server tasks are generated that have no results.
    In my workflow I would like to somehow predetermine if the reprovision will actually make changes and if not cancel the workflow. Is there some utility class that I can use to check for modifications or some option I can pass into the reprovision workflow to accomplish this? I probably could check the user.update.accounts[resource].changes before calling reprovision but that would seem to require a lot of express coding and comparisons.

    I don't have an answer for you but I do have a question. I have been researching the issue of which channels in the 2.4 band are permitted according to law in the various countries in Europe. We have offices in Germany, France, Spain, Netherlands and England and I was wondering which channels we are permitted to use. Do you know or could you point me to a document I could read?

Maybe you are looking for