2 identical Strings won't match?

hi, i have a program that takes some bytes out of a data file. It then checks to see if the data matches the
requested IDs. I have a strange problem. I have 2 different IDs that i have requested. When I request the first,
it works fine and the program selects properly. If I select the second, it also works fine and selects correctly.
However, if I select the first, get the correct results, and then try to select the second ID without restarting the
program first it will NOT select. I stepped through, and basically there is a comparison between 2 String that
is returning erronous conclusions. It works the first time around no problem, but for some reason when i am
in there the second time it won't match right. I tried using the '==' operator, the compareTo, and the
equalsIgnoreCase methods, all with the same result. Also, i get this same error no matter which order i put
the IDs in. I.e- i select 1st ID, get correct results, then try to select 2nd ID and get wrong results. It works the
same if I switch the ID selection order. Also, these IDs are number strings. Does anyone know why this is
happening? What am I missing here? thanks!

ooops! sorry, here is some code:
                                                      String claimID = new String();
                                                      String requestedID= new String("XXXXX"); //this is just so it won't match claimID
                                                      claimID = claim.substring(IDStart-1,IDEnd-1);
                                                       for(int p=0;p<requestNum;p++){//do this loop for each ID requested...
                                        requestedID = requests.getRequestedID(p);
                                        compare = claimID.compareTo(requestedID);
                                        //if(compare==0){
                                        if(requestedID.equalsIgnoreCase(claimID)){
                                             currentIDsMatch++; //if the IDs match, then increment this variable
                                             break;                                        
                                        }//end if
                                   }//end for
Notes: i just added the new String declaration because i thought the static nature of a declaration might
change the results. THe strange part is that i exit this function completely and come back to it between the
2 selections. Although this is inside a listener of a Swing Object that never dies in between so i guess it
never officially goes away..... does this help?

Similar Messages

  • Flash CS5.5 :Android App won't match screensize

    Hi,
    I have created an app for ipad recently with Flash CS5.5. It works just fine, but now I'm trying to publishing it for android devices such as the samsung Galaxy Tab 10.1. When I set the document dimensions to 1280x800 the app won't match the screen resolution of the tab and the app displays white bars for filling the gaps.
    I tried to enlarge the document width to 1380 pixel but the height won't fit on the other hand...
    I exported it landscape view and fullscreen.
    Thanks.

    As like that for 1024*768 for ipad, Is that the exact size of android tablet os is 1280x800? whatz ur dimension defined in the flash? Also these two lines of code in your project
    this.stage.scaleMode = StageScaleMode.NO_SCALE;
    this.stage.align = StageAlign.TOP_LEFT;
    Publish it in landscape and fullscreen. uncheck the autoorient while publishing.

  • Won't match my Serial Number?

    the website registration form won't match my serial number so i called the apple store. They said this was a known problem and to mail in the registration form. I've been looking all over the site but i don't know where to find the print out form.
    Also does anyone know how long after i mail it in will it take to register. I want to be able to buy iLife '09 soon

    We don't have that information. You will need to contact AppleCare.
    The Apple Discussions is a user-to-user help site. We have no connection with Apple and cannot speak for their policies and procedures nor now how long it might take for them to register your computer once you send in the information.
    The registration card came with your computer.

  • Search Array of String for exact match words

    I need to create a search feature.
    There will be a textfield where the user will input a word or words.
    Then I need to check if the are any reference in the array of names.
    namesArray ["ocean in the sky", "cean on sky", "cean is white"];
    keywordsArray ["cean", "sky"];
    matchCounter = 0;
    If I input the word "cean" I dont want in my results "ocean in the sky", only "cean is sky".
    I have the following code:
    for (var j:int = 0; j < namesArray.length; ++j)
         var tempStr:String = namesArray[j];
         for (var k:int = 0; k < keywordsArray.length; ++k)
              if (tempStr.indexOf(arrayKeywords[k]) != -1)
                  matchCounter++;
         if(lengthKeywords == matchCounter)
              trace("yeahhh... there's a match!!");
         matchCounter = 0;
    Is there a better way? How can I do this?

    There are few things but the main problem is that "new RegExp()" needs double escapes ("\\")
                var namesArray:Array = ["ocean in the sky", "cean on sky", "cean is white"];
                var keywordsArray:Array = ["cean", "sky"];
                for (var j:int = 0; j < namesArray.length; j++){
                    var matchCounter:uint = 0;
                    var tempStr:String = namesArray[j];
                    for (var k:int = 0; k < keywordsArray.length; k++){     
                        var regExp:RegExp = new RegExp("(\\s+|^)" + keywordsArray[k] + "(\\s+|$)"); 
                        if (tempStr.search(regExp) > -1){
                            matchCounter++;
                    if(keywordsArray.length == matchCounter){
                        trace("\"" + namesArray[j] + "\" matched all the keywords");
    Traces:
    "cean on sky" matched all the keywords

  • Looping around an arraylist of strings to find matches(more complicated!)

    Total Posts: 1
    Help developing an algortim
    Posted: 03-05-2006 07:11 AM
    Hi,
    I have been bashing my head with this for a while, so any help is much appreciated!
    I bascially have ONE arraylist which contains filenames as strings (e.g. file.txt, file1.xml, file2.doc, file2.xml, file2.txt)
    The arraylist bascially contains a document name with there associated metadata document names. For example file1.doc (document file), file1.xml (metedata file).
    There will be siuations where for example file1.doc may not have an associated file1.xml file with it. And there may be situations where there are 2 documents and only one associated metadata file (e.g. file.doc, file1.txt, file1.xml)
    I basiclaly need to loop arond the arraylist identifying only files names that:
    - have an associated metadatafile (once identified put the document name in an arraylist of matches)
    -this arraylist cannot contain duplicate documents with an associated file name (e.g. file.doc, file1.txt, file1.xml), if this particualr situations occurs I want to put these filenames in an arraylist of errors.
    Please help! thanks in advance

    I'm a little lost as to how
    >(e.g. file.doc, file1.txt, file1.xml)
    contains duplicate documents with an associated filename. Either the .txt and .xml are both metadata files, and you are saying that there should never exist two metadata documents of the same name, or else you meant to say
    (e.g. file1.doc, file1.txt, file1.xml)in which case you meant that two data files (the .doc and the .txt) with the same name (file1) cannot exist together if there exists a metadata .xml of the same name.
    Assuming the latter is true, try something like this: (hot off the grill ;)
    import java.util.*;
    public class Blah {
       public static void main(String[] args) {
          List<String> fileNames = Arrays.asList( new String[] {
             "File1.txt", "File2.txt", "File1.xml", "File1.doc", "File1.blah", "File3.doc",
             "File4.xml", "File4.txt", "File5.doc", "File6.doc", "File6.xml", "File7.csv",
             "File7.xsl", "File7.xml", "File8.xml", "File9.doc", "File90.txt"
          String metadataExtension = "xml";
          Map<String, Set<String>> pendingFileNames = new TreeMap<String, Set<String>>();
          Set<String> metadataNamesFound = new TreeSet<String>();
          Map<String, String> verifiedMetadataFileNamePair = new TreeMap<String, String>();
          Map<String, Set<String>> verifiedBadFileNames = new TreeMap<String, Set<String>>();
          Set<String> verifiedFileNamesWithoutMetadata = new TreeSet<String>();
          Set<String> verifiedMetadataWithoutFileName = new TreeSet<String>();
          for (String fileName: fileNames) {
             String[] halves = fileName.split("\\.");
             System.out.println(halves[0]+" "+halves[1]);
             String nameOnly = halves[0];
             String extension = halves[1];
             Set<String> associatedExtensions = pendingFileNames.get(nameOnly);
             if (associatedExtensions == null) {
                associatedExtensions = new TreeSet<String>();
                pendingFileNames.put(nameOnly, associatedExtensions);
             if (extension.equals(metadataExtension)) {
                metadataNamesFound.add(nameOnly);
             } else {
                associatedExtensions.add(extension);
          for (String name: pendingFileNames.keySet()) {
               Set<String> fileExtensions = pendingFileNames.get(name);
               boolean metaNameWasFound = metadataNamesFound.contains(name);
               String fullMetaName = name+"."+metadataExtension;
               if (fileExtensions == null || fileExtensions.size() == 0) {
                 if (metaNameWasFound)
                     verifiedMetadataWithoutFileName.add( fullMetaName );
               } else if (fileExtensions.size() == 1) {
                  String fullFileName = name+"."+fileExtensions.iterator().next();
                  if (metaNameWasFound)
                     verifiedMetadataFileNamePair.put(fullFileName, fullMetaName);
                  else
                     verifiedFileNamesWithoutMetadata.add(fullFileName);
               } else {
                 if (metaNameWasFound)
                     verifiedBadFileNames.put( name, fileExtensions );
                  else {
                    for(String extName: fileExtensions) {
                        verifiedFileNamesWithoutMetadata.add(name+"."+extName);
          System.out.println();
          System.out.println();
          // System.out.println(pendingFileNames);
          System.out.println("Verified one-to-one file/metadata pairs: \n"+verifiedMetadataFileNamePair);
          System.out.println("\nVerified errors (more than one document to one metadata): \n"+verifiedBadFileNames);
          System.out.println("\nVerified metadataless files: \n"+verifiedFileNamesWithoutMetadata);
          System.out.println("\nVerified fileless metadata: \n"+verifiedMetadataWithoutFileName);
    }

  • What is the Scan from string pattern for "match everything" ?

    Hello,
    Using Scan from string for a while, I know that %s only matches string up to a whitespace. And I also thought %[^] would match everything including whitespaces. But it turned out that it would stop at the closing square brace.
    So, what is the real scan pattern for match everything including whitespaces ?

    What do you want the Scan From String to end on?  Or are you just grabbing the rest of the string?  If that is your scenario, then just use the "remaining string" output.  It might help if you give a full example of a normal input string and EVERYTHING you want as an output.

  • In "Match First String", 13 is matched with 1

    I find a weird thing with "Match First String".
    with a string array holding '1', '3', '13', the index for string '13' is 0. is there any revised version of String match available?  thanks.

    I cannot see the problem.
    Please attach a small program containing useful defaults in all controls.
    Let us know
    What you get as result
    What you expect as result.
    I believe that if you have an arrray containing the strings [1,3,13] and a string of "13", 0 is the correct index result. Is that what you are doing?
    (Element 0 of the array is the first element that matches the beginning of "13" (the "1"!), so the output string="3" and index=0.)
    LabVIEW Champion . Do more with less code and in less time .

  • Versioning of shell scripts in Sun Solaris 9? (ident-string)

    Dear all,
    I have got a question about the versioning of shell scripts (e.g. start/stop scripts) in Sun Solaris 9:
    In every shell script I can find an information-"header" like ' ident "@(#)<name_of_script> <version> <date> SMI" '. Is this an "sun internal" or ist there a versioning-database or something else on Sun Solaris? If yes, is there a way to check in my own shell script there?
    Best Regards,
    Alex....

    That's a Sun internal revision control string. However, that doesn't prevent you from setting-up your own RCS (or CVS) archive for maintaining customizations. You can add your own RCS tags and check them into an archive. You can get RCS and CVS from http://www.sunfreeware.com/ .
    HTH,
    Roger S.

  • My Norton Identity Safe won't work with the new version (4) of Firefox AND the new version isn't asking me to Remember my password info either - SO I now have to type in my password info wherever I go which is NOT a good thing. What can I do???

    I have Norton Internet Security.
    When I downloaded the new FF4 they said that a part of Norton wasn't compatible - and it seems that that part must have been my Identity Safe which holds all my password info & fills in all of my passwords for me.
    You say this new version of FF automatically prompts me to have it save this info for me, but I sure didn't see that prompt and now every time I visit my online banking (and credit card site, etc, etc,) I have had to type in all this info myself.
    This certainly is not convenient!
    It's bad enough I just get used to one system and you all go & reinvent the wheel -BANG!
    Hasn't anyone ever heard of baby steps?

    Hmmm, Norton extensions are broken again in Firefox 4.0.1. It seems that Norton didn't allow for Firefox 4.0 security updates when they updated their Firefox extension for Firefox 4.0. Norton says they'll have a fix in two weeks. A Norton user posted a fix in this forum thread.
    http://community.norton.com/t5/Norton-Internet-Security-Norton/Norton-Toolbar-not-compatible-with-FF-4-0-1/td-p/442788

  • HELP: How do I recover mail from an old identity that won't rebuild?

    I am using Outlook for Mac 2011 and in the process of trying to fix my email that had been duplicated (since the install of Mavericks) Outlook suddenly froze and I had to hard reboot my machine.  On reboot I was told I had to rebuild the identity, but no matter what I've tried the rebuild would get all the way to step four and then say its not possible with error code -18000.  I finally managed to create a new identity so as least I can open Outlook again, but now how to I recover all my old emails and info that was stored in my old database?  I have no Time Machine or any other backup (yes I'm stupid...and yes I will immediately be setting up a backup protocol for myself) so all I have is the old database files (no .olm either).  Is there anything I can do?  I've searched for answers but haven't found anything so would very much appreciate some guidance.
    Thanks in advance

    http://www.office.mvps.org/get_started/outlook.html
    http://www.officeformachelp.com/2012/05/how-to-recover-your-data-when-rebuilding -restoring-and-upgrading-fails/

  • ISE won't match configured profiling policy

    I'm trying to match Cisco LAPs (any kind of) using profiling in my AuthZ policies, yet the specific AP (a 1252 model) always gets profiled as 'Cisco-Aironet-AP-1250' instead of the desired, more generic 'Cisco-AIR-LAP' policy. To change this behaviour, I've tried to work with a simple match ('LLDP:lldpSystemDescription CONTAINS K9W8') and give this policy a high certainty factor of 150, yet it doesn't work.
    How can I force any kind of LAP (that must not contain any autonomous AP) to get profiled in a generic LAP policy which I can use in an AuthZ policy?
    I'm using ISE 1.2, patch 6.
    Thanks, Toni

    Hi, thanks for your reply. That's almost a winner...meanwhile, I escalated this to TAC. Basically, attribute value "cisco AIR-LAP" would do, but there's a bug that needs to be considered with ISE 1.2, patch 6:
    https://tools.cisco.com/bugsearch/bug/CSCuo78457

  • CS3 color management won't match prints

    Okay, I know there are a lot of boneheds who can't figure out how to set up color in Bridge and CS3 but I am at my wits end on this so bear me out.
    Windows XP and CS3
    Bridge is set to; Enable color management in Bridge
    RAW conversion is SRGB
    CS3 color settings/working space set to SRGB
    Print color management is set to SRGB and Photoshop manages colors
    Printer is set to "application manages colors" (HP B9180)(btw, I have also tried it set to SRGB)
    Image looks the same on Bridge, RAW conversion, CS3 and print screen (dark)Image looks LIGHTER when viewed with any other program (including windows picture and fax viewer, HP print program, Paint Shop Pro and online) and prints to match the lighter image both on my HP and from my lab!
    The closest I have been able to get to a total sync is to set Photoshop's color settings to "Monitor color," and uncheck the box in Bridge that says "apply color management settings in Bridge." In that case, Bridge and CS3 produce a lighter image but RAW conversion is still darker. Plus, who the hell wants to use monitor color in Photoshop!?

    That's pretty much it David... I could get Photoshop to match my prints but then any other program would show the prints as being waaaay off-color.
    Today I bought a spider2express and color balanced my monitor. Now everything seems to look in sync and my prints match very close (a little warm for my tastes..). Tech support at Photoshop told me it was a calibration issue but I thought that was bull... i mean, how can calibration make an image that looks different in two different programs look the same? Well, it does. As far as I understand it now (layman's terms)when you look at an image in windows viewer ot explorer or any other non-color management program you are looking at the image based on your monitor profile. When you look at the same image in photoshop the program uses it's own color management which then gets filtered through your monitor program to your eyes (but not to the printer). If your monitor profile is bad, the image looks bad.
    Or something like that :)

  • String won't copy to array

    I had to create an applet that would take in two binary numbers from the keyboard and would add/subtract/multiply them. To do this we needed an int array. But when i tried doing the method shown to us, it didnt work and it would literally output garbage. It was already due and i submitted it as is but this'll bug me unless i figure it out. The calculations should work (i think) but once i get the array problem fixed i could debug that. Thanks in advance.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    public class proj2 extends JApplet implements ActionListener{
        JLabel p1, p2,answer;
        JTextField i1,i2;
        JButton plus, minus, multi;
        public void init(){
            p1=new JLabel("Enter first integer");
            p2=new JLabel("Enter second integer");
            i1=new JTextField(20);
            i2=new JTextField(20);
            plus=new JButton("+");
            minus=new JButton("-");
            multi=new JButton("*");
            answer=new JLabel("Answer is          ");
            JPanel north=new JPanel();
            north.setLayout(new GridLayout(2,2));
            north.add(p1);
            north.add(i1);
            north.add(p2);
            north.add(i2);
            JPanel south=new JPanel();
            south.setLayout(new GridLayout(1,3));
            south.add(plus);
            south.add(minus);
            south.add(multi);
            Container c=getContentPane();
            c.setLayout(new BorderLayout());
            c.add(north,BorderLayout.NORTH);
            c.add(answer,BorderLayout.CENTER);
            c.add(south,BorderLayout.SOUTH);
            plus.addActionListener(this);
            minus.addActionListener(this);
            multi.addActionListener(this);
            }//end init
                public void actionPerformed(ActionEvent x){
                    String a=i1.getText();
                    String b=i2.getText();
                    int[] top=new int[20];
                    int[] bottom=new int[20];
                    int[] ans=new int[20];
                    int[] one=new int[1];
                    one[0]=1;
                    int len=a.length();
                    int len2=b.length();
                    for (int i=len-1;i>=0;i--)
                            char c=a.charAt(i);
                            top[len-i]=(c-48);
                    for (int i=len2-1;i>=0;i--)
                            char c=b.charAt(i);
                            bottom[len2-i]=(c-48);
                    if (x.getSource()==plus){
                    ans=addbin(top,bottom);
                    answer.setText("The sum of "+top+" and "+bottom+" is "+ans+".");}
                    else if (x.getSource()==minus){
                    bottom=flipbits(bottom);
                    bottom=addbin(bottom,one);
                    ans=addbin(top,bottom);
                    answer.setText("The difference of "+a+" and "+b+" is "+ans+".");}
                    else {
                    for(int i=0;i<20;i++)
                        if (bottom==1)
    ans=addbin(ans,top);
    top=shift(top);
    answer.setText("The product of "+a+" and "+b+" is "+ans+".");
    }//end actionPerformed
    public int[] addbin(int[] x, int[] y){
    int carry=0;
    int[] ans=new int[20];
    for(int i=0;i<20;i++)
    int sum=x[i]+y[i]+carry;
    ans[i]=sum%2;
    carry=sum/2;
    return ans;
    }//end addbin
    public int[] flipbits(int[] x){
    for(int i=0;i<20;i++)
    x[i]=(x[i]+1)%2;
    return x;
    }//end flipbits
    public int[] shift(int[] x){
    int len=x.length;
    int[] newarray=new int[len+1];
    for(int i=0;i<len;i++)
    newarray[i]=x[i];
    newarray[len]=0;
    return newarray;
    }//end shift
    }//end class

    jlicata89 wrote:
    int[] ans=new int[20];
    answer.setText("The sum of "+top+" and "+bottom+" is "+ans+".");}
    answer.setText("The difference of "+a+" and "+b+" is "+ans+".");}
    answer.setText("The product of "+a+" and "+b+" is "+ans+".");
    You can't just append an array to a string. Arrays don't have a custom "toString" method, so its string representation is the default one, which looks like "garbage" to you. Depending on what you want to do, you can use Arrays.toString(), or write a custom method to turn it into a string representation of your choice.
    l33tard wrote:
    Try changing all occurrences of this:
    top[len-i]=(c-48);to:
    top[len-i] = (int)(c) - 48;
    That is completely useless. char's are automatically promoted to int's.

  • Color libraries won't match in AI and PS CS3

    Hey guys, perhaps a newb question here...
    I have been trying to get my PMS libraries to sync up between illustrator and photoshop.  I have selected pantone solid coated 375 in the photoshop color library and the illustrator swatch library and lined them up side by side on the same monitor.  The illustrator side looks very desaturated and the photoshop nearly matches my color book.  I have tried syncing the color management settings in bridge, both are using the same profiles, and both are in RGB mode without proof colors being viewed.  What's weird is I tried to open the photoshop PMS library in Ilustrator, and it looked exactly the same as the desaturated one.  Any clue on how to get the Illustrator to show the library properly?
    Thanks!
    Micah

    Hey guys,
    You might want to sticky this or make a note of it.
    I found the answer to my question after a lot of research.  The problem is the illustrator (as well as indesign) for the CS2 and CS3 versions both default to their legacy CMYK color books given by the manufacturers.  Photoshop, however, has used the Lab version from the color book manufacturers for quite a while.  Anyhow, the CMYK color books are chosen by default in CS2 and CS3, however, Lab is selected in CS4 from what I've read.  To fix it, this is what you should do:
    1.  Open your swatch pallete
    2.  Open your swatch pallete options
    3.  Select "Spot Colors"
    4.  Click on "use Lab values specified by the book manufacturer
    5.  Click OK.
    You're setup!  At least until you close the program, you'll have to save the UI profile to have it stay that way.
    Thanks to everyone for your help!
    Micah

  • Query string won't work

    I am loading a local swf using MovieClipLoader. Here's the relevant bits of code:
    mcloader = new MovieClipLoader();
    createEmptyMovieClip(clipName, getNextHighestDepth());
    mcloader.loadClip("test.swf", clipName );
    This works fine. However, if I try to add a query string as follows:
    mcloader.loadClip("test.swf?var1=2", clipName );
    Then I get an error like follows:
    Error opening URL 'file:////Volumes/Macintosh%20HD/Users/.../test.swf?var1=2'
    Why can't I use a query string?

    Because you are loading a file, not linking a url.

Maybe you are looking for