Wierd IF statment problem

Here's the source:
String testText = answer1[aC];
JOptionPane.showMessageDialog(null,testText,"Test",JOptionPane.PLAIN_MESSAGE);
if(testText == "yes"){
JOptionPane.showMessageDialog(null,"Success!","Test",JOptionPane.PLAIN_MESSAGE);
The Message Dialog shows "yes" (without the quotes) when it pops up, but the if statement is never true. answer1[] is a srting array which is built from a database. I have also tried:
String testText = String.valueOf(answer1[aC]);
String testText = answer1[aC].toString;
I also tried to modify the the first message dialog like this to eliminate the possibility of leading or trailing spaces:
JOptionPane.showMessageDialog(null,"." + testText + ".","Test",JOptionPane.PLAIN_MESSAGE);
Case matches perfect, infact, I can tell you that the word 'yes' has 56 pixels in it on my current font (that's how hard I have studied why yes != yes). Now, if I change the first line of code to say:
String testText = "yes";
That works fine. Any help??

Be careful when using the "==" operator to compare objects - especially strings - in Java. The "==" operator will return true if and ONLY if the two strings are the same reference (i.e. point to the same location in memory). So the following would not work:
String string1 = "Hello";
String string2 = "Hel" + "lo";
if (string1 == string2)
  System.out.println("This won't print!");There is a method in the String class (actually in the Object class, but it is overridden in String) called equals() that will return true if the two strings are equivalent (i.e. same contents, even if they are located in different areas of memory). So we could fix the above to look like this:
String string1 = "Hello";
String string2 = "Hel" + "lo";
if (string1.equals(string2))
  System.out.println("Now we see the print statement");

Similar Messages

  • Wierd monitor compatibility problem

    Hi all,
    Got a wierd monitor compatibility problem. G3 works fine on a sony 21" CRT.
    Connected it to a Daytec 15" CRT which works fine with a windows 98 PC.
    With the G3 I get the apple and the spinning up logo then the screen just goes blank.
    Is this monitor PC only or something? It is an old monitor but I thought any monitor should work
    if the vga connector fits?

    So you are using this directly plugged into the stock Display card in a Blue & White G3 with NO adapter?
    The Mac is probably still set for a higher resolution that the SONY can do, and has not noticed the display has changed.
    Video pros says that Video can be plugged and unplugged all day long with no bad effects. If your old display is still around, try setting it to 640 by 480, save changes, and swap the other one in "live" at that resolution.
    Other tricks:
    Reset the PRAM. This will send you back to a default setting while booting up, but may change when the system becomes active.
    Boot from a CD. This ignores the settings on your Hard drive, and boots to a very simple resolution like 640 by 480 to ensure that Most Macs can start up with it.

  • Wierd email download problem...losing messages

    Anyone else had this problem - you download messages on iPhone - and often get the dreaded "no content" or "did not download message from server" message - and then when you try to download message on primary computer the message never shows up? (And yes, the iPhone is selected to "leave message on server".) This has happened several times now....some times the message shows up hours or days later, some times not at all. I am using a POP account on a Macbook pro. Any explanation? Thanks in advance!

    That's normal behavior if you are using an IMAP email service.

  • Wierd Mac Installer problems

    Im not sure why but i cant get any .pkg files to install properly. At some point in the installation the UI becomes totally un responsive and i get the spinning beachball of death. This happens for me with various pkg files, namely the iPhone SDK installer and the Onyx installer package?
    Does anyone have any ideas?

    See my post with this same post date in the topic iLife '09 installation problems; run preflight script error for one possible cause of this behavior.
    It also could be that you need to run the "Permissions Repair" option in Disk Utility's First Aid tab to correct some permission on a system file used during the installation procedure; that your drive's file system needs to be repaired with the "Repair Disk" option; or that the drive does not have adequate free space to complete the installation. (As a rule of thumb, try to leave 10 to 15% of the startup volume's capacity free, or at lease 5 GB over & above whatever the installer tells you is needed for the install itself.)
    As a general rule, it is a good idea to quit all other applications before doing an installation that uses Apple's Installer.app, & it may be necessary to disconnect non-essential peripherals (everything except the keyboard, mouse, & monitor) & restart before doing so. You should also consider removing any hacks or uninstalling any third party "enhancers" that modify basic system behavior before doing installs, or at least making sure that the latest versions of such things are installed. (Some "enhancers," especially "Application Enhancer" -- a.k.a "APE"-- are installed by other third party products & their developers do not always make that clear, so do not assume one of these things is not on your Mac just because you have not installed it directly.)

  • Select statment problem

    Hi all,
    I am trying to put select statment into another select statment.
    Select column1
    ,column2
    ,column3
    ,(select column1 from table1,table2,table3 where condotions...)
    ,column4
    from table 1.
    its giving me error.
    Please help me...its urgent.
    Surender

    SQL> select deptno,dname,(select ename from emp) from dept;
    select deptno,dname,(select ename from emp) from dept
    ERROR at line 1:
    ORA-01427: single-row subquery returns more than one row
    SQL> select deptno,dname,(select ename from emp where empno=7934) from dept
    DEPTNO DNAME (SELECTENA
    10 ACCOUNTING MILLER
    20 RESEARCH MILLER
    30 SALES MILLER
    40 OPERATIONS MILLER
    In your case subquery is returning more than one row. It should not be.
    -aijaz
    Message was edited by:
    [email protected]

  • Update statment problem

    I having a problem using th following preparded statement:
    String updateDatabase = "UPDATE titles SET titles.isbn = ? WHERE titles.isbn = "+ISBN+"";//ISBN is a string already initialized
    preStatement = connection.prepareStatement(updateDatabase);
    preStatement.set.setString(1,Sisbn);//Sisbn is a string to update database.
    preStatement.executeUpdate();
    preStatement.close();
    This of course is inclosed in a try catch.
    However, when I run this I get the following error:
    Data type mismatch in criteria expression.
    The field in the database is text so I don't see what could be the mismatch. Any help would be appreciated.

    1) You didn't quote the value in the where clause
    2) Why can't you use another parameter (?) and set that, too? Example from the docs:PreparedStatement pstmt = con.prepareStatement("UPDATE EMPLOYEES
                                         SET SALARY = ? WHERE ID = ?");

  • Wierd duplicate rows problem

    Hi,
    I've a partitioned table and when I query to extract primary keys for a particular month, I'm getting wierd results. Here is what is happening -
    SELECT colA, colB, colC
    FROM tableA partition(Y06M01)
    WHERE current = 'Y'
    -- This query is returning me some duplicate rows for colA, colB, colC when these columns form primary key on tableA. Note that, rowids for these rows are not repeating, which makes me think oracle is actually storing these duplicate rows on the drive.
    Now, for the values that are repeating in the above query, following query doesnt result in duplicate rows (note that I'm not mentioning partition name in the from clause) -
    SELECT colA, colB, colC
    FROM tableA
    WHERE current = 'Y'
    AND (
    (colA = <val1> AND colB = <val2> AND colC = <val3>)
    OR
    (colA = <val4> AND colB = <val5> AND colC = <val6>)
    OR
    (colA = <val7> AND colB = <val8> AND colC = <val9>)
    Does anyone know why such a thing is happening? is it some kind of internal oracle error?
    Thanks

    Answers to your questions
    FROM tableA partition(Y06M01)Why have you need to query against the partition instead of table level ?
    -- There's no need, but the rows that are repeating lie in this partition. Hence, querying against the partition or against the table should return same results.
    colA, colB, colC when these columns form primary key on tableAAre they a primary key created ?
    -- Yes there's is a primary key created on these columns.
    Anyway, have you just some example output to show us.
    -- Here is the sample output:
    Scenario I (If I query against the partition). In this case if i extract rowids, they are different for each of below selected 6 rows
    colA colB colC
    1 2 3
    4 5 6
    4 5 6
    4 5 6
    7 8 9
    7 8 9
    Scenario II (If I query against the table for values (1,2,3), (4,5,6) and (7,8,9))
    colA colB colC
    1 2 3
    4 5 6
    7 8 9
    Furthermore, generally, to see the duplicate rows, try this query :
    select colA, colB, colC, count(*)
    from tableA
    having count(*)>1;
    -- I did run this query and again if I query against the partition I see duplicate rows and when I query against the table there are no duplicate rows.

  • Wierd Font symbol problem - possibly only win7

    Hi guys, what the hell is going on here.  I've the same symbol, the greater than or lequal to symbol.
    Now In static text it looks fine, but in dynamic text is looks wierd.  See screenshot with attached fla.
    Any ideas?  I can't embed fonts because the application I'm putting this into won't allow me to.
    It looks like it is using a different font of some sort, but why? The textbox is Arial and certaintly has that font symbol in it's library.
    It seems fine on every win xp machine I've tested but some of my users on win 7 are having issues.

    Hi again, As I said in my first post:
    "I can't embed fonts because the application I'm putting this into won't allow me to."
    My question is why is flash doing this and is there a way around it without embeding?  In my opnion this is clearly a bug!
    I dont see why a dynamic text box would be displaying a different font when clearly I have this font with the correct symbol in it.  this makes no sense

  • Wierd Email sending problem

    Hi,
    I used my email server, for example, "email.ZZZ.edu", to send email by the following code:
    Properties prop = System.getProperties();
    prop.put("mail.smtp.host","email.ZZZ.edu");
    Session session = Session.getDefaultInstance(prop, null);
    InternetAddress fromAddress = new InternetAddress(SendFrom);
    InternetAddress toAddress = new InternetAddress(SendTo);
    replyadd[0] = new InternetAddress(ReplyTo);
    MimeMessage emailmsg = new MimeMessage(session);
    emailmsg.setFrom(fromAddress);
    emailmsg.setRecipient(Message.RecipientType.TO, toAddress);
    emailmsg.setSentDate(new java.util.Date());
    emailmsg.setSubject(Subject);
    emailmsg.setText(EmailContent);
    Transport.send(emailmsg);
    When I send out an email to a person who is under the same email server, it works(e.g., from "[email protected]" to "[email protected]"). However, if I send to an email address that is not under the same server (e.g, from "[email protected]" to "[email protected]", I got the following error msg:
    >>>>>>>>>>>>>>>>>>>>>>>
    Email Sending Exception: javax.mail.SendFailedException: Sending failed;
    nested exception is:
         javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
         javax.mail.SendFailedException: 554 <[email protected]>: Recipient address rejected: Relay access denied
    So it seems sending to an outside address from my own email server doesn't work.
    However, on the contrary, if I send an email from [email protected] to my address "[email protected]" by using my email server "email.ZZZ.edu", it works. You see, this will cause security problem, that means, a person can send to me an email by using an forged email address.
    Does anybody knows how to solve the above two problems? Thanks in advance,
    Yihua

    What are you using for SMTP services? It looks like you have it setup to only relay messages to its own domain but accept messages for relaying from any where.
    I would talk to whoever setup the service to get it configured to relay messages anywhere but accept requests from your domain only. Your Java code looks fine and does work so I think you just need to get the environment setup right.
    Sean

  • Wierd Mail.app Problem

    Hi all,
    I use Mail.app on a dual 2Gig G5 with 10.4.9. I have a variety of POP and IMAP accounts. All function well, including Mac.com, except for a Cox.net POP account which can send but not receive mail. The account setup (send receive servers & ports) has been confirmed to be correct, and I'm able to access my Cox mail via their webmail portal.
    Thoughts, anybody?
    I just had a non-productive chat with a Cox techie who recommended that I call Microsoft for Outlook assistance. So much for Cox's expertise.

    You’re welcome.
    Sometimes messages left on the server clog up the account there, or Mail chokes on a message it cannot download and that prevents it from downloading the rest as well. Solving this problem will probably require removing one or more messages from the server. What are your Preferences > Accounts > Advanced > Remove copy from server settings for this account?
    You may tell Mail to remove from the server all the messages that have already been downloaded by means of Preferences > Accounts > Advanced > Remove now. Alternatively, you may use the Account Info window to remove specific messages from the server — choose Get Info (⌘I) from the Action menu (gear icon) located below the mailbox list in the main Mail window. And if the account allows web access, you may also remove messages from the server that way.
    Try removing from the server messages that have already been downloaded and/or the first message not downloaded yet (i.e. the message that Mail appears to be choking on).
    You may want to try to download those messages with another mail client such as Thunderbird first, to avoid losing them — and use Eudora Mailbox Cleaner to import them back into Mail afterwards if you wish.

  • Wierd Radio Button Problem

    can we set the value of a radio button at runtime?
    Suppose there are two radio buttons: Yes and No.
    Suppose a user chooses Option1 from a drop down list, then Radio button Yes should be highlighted, if the user chooses Option 2 from the drop down list, then the Radio button No should be highlighted.
    I am trying the following code but its not working:
    if (option.rawValue == Option1)
    radioButton1.rawValue = true;
    else
    radioButton2.rawValue = true;
    Is it the rawValue property of radio button that I should use or something else?
    I am really stuck on this. Any help would be highly appreciated

    It's called RadioButtonList a "group" of radio options.
    In your example, in one RadioButtonList, you have 2 options: Yes and No. You should specify a value for each option in the RadioButtonList's Binding tab.
    By doing this you're able to change the value at run time:
    form1.subform.RadioButtonList.rawValue = "1"; // for Yes option.
    an so on.
    I hope this helpful.
    Diego

  • Wierd MS Word Problems

    Ever since 10.4.3, when I scroll up and down the document, there are cut off lines that repeat many times. Also, when I resize the widow, it does funky things, not letting me do what I want, and sometimes, I get a frame within the window, which I can't adjust properly. When I save it, it's fine. After re-opening, the same thing happens. Tried many documents – the same thing happens. I'm using Word version 11.2.
    What's going one?
    PB 1.67 15 Superdrive   Mac OS X (10.4.2)  

    Sorry for the typo.
    What's going on?

  • Try-catch statment problems

    I'm trying to understand the try-catch statements. I'm trying to verify that a number entered is only within a range of 1-3, otherwise get the input again. But I'm not grasping the try-catch statements very well, and my code isn't working correctly. It seems to just by pass the catch statement completely. Any idea on what I'm doing wrong with this?
              try {
                   System.out.println("Enter the test number");
                   testNumb = scan.nextInt();
                   if(testNumb < 1 && testNumb > 3){
                        throw new Exception("Test Number not valid");
              catch(Exception e){
                   System.out.println(e + "please enter a valid test (number between 1-3)\nEnter the test number");
                   testNumb = scan.nextInt();
              }

    I don't understand why its still crashing, when it should catch the InputMismatchException, and run the code INSIDE of the exception, which asks the user to enter the input again. It does ask the USER, but it still just crashes.
    I've changed the method around so it is more like what post #8 said. But its still crashing, I'm not sure if its something specific I dont understand, or what.
         public static int studentTest(){
              Scanner scan = new Scanner(System.in);
              boolean acceptable = false;
                   while(!acceptable){
                        try {
                             System.out.println("Enter the test number");
                             testNumb = scan.nextInt();
                        catch(InputMismatchException ioe){
                             System.out.println("Test Number not valid, please enter a valid test (number between 1-3)\nEnter the test number");
                             testNumb = scan.nextInt();
                        if(testNumb < 1 || testNumb > 3){
                             System.out.println("Test Number not valid, please enter a valid test (number between 1-3)\nEnter the test number");
                             testNumb = scan.nextInt();
                        } else {
                             acceptable = true;
                   return testNumb;
         }

  • Wierd Problem with Logitec mouse

    I doubt this is board related but then again what do I know
    I have a logitec MX 510 optical mouse.  Driver version 980.
    I get the wierdest audio feedback when browsing the internet.  My mouse squeaks when I scroll pages.  I am also getting sound feedback from my hard drive and fans but it's comming through my speakers/head phones.   I did a clean install and tried "all two" of the different versions of the Logitec drivers for this mouse.
    I still here the squeek even with the volume shut down completely.
    The only thing I havent tried is using different chipset and audio drivers from Nvidia.  I am using the current ones from there website.  I don't think it's a sound driver problem though due to the squeeks and noises being audible with the volume turned all the way down.
    I personally think it could be a USB problem or board problem.  Maybe even a mouse problem..
    Seems like a wierd power feedback problem or something to me.  
    I'm going to keep working on it.  
    I came here because you guys always seem to have some good suggestions and are willing to help.  I will not get my feelings hurt if you don't have any ideas for this problem.   I know it's wierd...
    Although if you did,  I would really appreciate any of you input.
    Thx again

    I have the same problem, but using  different equipment.  K7N2 Delta-L and a no-name Optical mouse.  I get the noise/squeek upon moving the mouse.  It's not loud, but it is there.  
    It has to do with the optics of the mouse, because if you lift it off the mouse pad = no noise.  If it is staionary = no noise.  If you move it when all other  functions are silent, then the feedback.  I have tried both the NVIDA and the REALTEK audio drivers, same problem.  My next test will be a different mouse.
    Any one else hear this noise?

  • Unique (?) problem Kid Pix & dvd

    Working in an educational setting, students make projects using Kid Pix. The file can be saved (or technically, exported) as a quick time movie.
    I'd like to put these QuickTime movies into a DVD using iDVD but I am having problems.
    Basically, the video doesn't encode (following status--background encoding) -- I know that it should show DONE--and it doesn't show anything...no progress at all.
    So, if I go to burn, it goes through everything until the actually burning...and the message comes up that iDVD has unexpectedly quit. This has happened more than once...I've been trying for a few days.
    The quicktime is saved as a .mov file
    I've tried moving the files (originally on an external firewire, I've moved to the desktop.
    I've tried at home, at school...I don't want to waste anymore bland DVD
    Thanks for any help.

    To add my thoughts. Are you SURE this is Kids Pix related? It might just be a coincidence and really you are just having troubles with burning DVDs period. So my first thought is, have you tried burning another project that doesn't contain any K.P. QT imports? Also, have you tried "burning" the project to a disc image rather than directly to a DVD blank?
    My standard list of things to do first for these wierd sort of problems, but I also tend to run these before I go to burn an iDVD project just to be safe. Keep in mind this list represents the programs I tend to use. There are several alternate programs that do the same things with some combining the functions of some of the ones below. So everyone has their favorites, but here are mine...
    Run MacJanitor (free download) to do all the Unix Cron Maintenance scripts.
    Run Disk Utility (Applications -> Utilities) and repair disk permissions on your start up drive (typically your internal drive). Also verify any other drives mounted on the system, especially any external drives that you use for iMovie and iDVD projects.
    Run Preferential Treatment (free download) to check for corrupt/damaged application and system preference files.
    Run Cache Out X (free download) to clear all system and application caches.
    Reboot your Mac (after running Cache Out X you are given the option to restart the machine).
    If you still can not get it to run correctly, next thing to try is to throw out the iDVD preference file (don't forget to change back those preferences you want different from the defaults next time you run it).
    Patrick

Maybe you are looking for