Results 1 to 10 of 10
  1. #1
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Need some help with quick question

    Ok, so I have a textpane with this:

    doc.insertString(doc.getLength(), "colour: " + colour + "\n", null);


    if ((colour.equalsIgnoreCase("Red")) ||(stockExchange.equalsIgnoreCase(""))) {
    doc.insertString(doc.getLength(), "group: prime \n", null);

    In the pane, the first part works, but the second part telling the group doesn't show up, can someone clear this up.

    Thanks alot, much appreciated

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Need some help with quick question

    but the second part telling the group doesn't show up,
    Is the if statement ever true?
    Print out the values of the two expressions used in the if statement to see if either of them are ever true.

  3. #3
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: Need some help with quick question

    they are true , i have no idea why it isn't working

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Need some help with quick question

    no idea why it isn't working
    The conditions in the if printed out as true when you added a println?

  5. #5
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: Need some help with quick question

    ye they are true

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Need some help with quick question

    If one of them is true, then the insertString() method will be called.

  7. #7
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: Need some help with quick question

    why isn't it workinng for me than?

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Need some help with quick question

    Try changing the insertString() method.
    For example swap it with the other one you posted.

    You'll have to post working code for anyone to see what your code is doing.
    Make a small program (SSCCE) that compiles, executes and shows the problem and post it.

  9. #9
    stuckonjava is offline Senior Member
    Join Date
    Jan 2012
    Posts
    151
    Rep Power
    3

    Default Re: Need some help with quick question

    The thing is, I'm shwoing the variable colour in the pane, and it shows up as the string and it shows up as Red.
    I don't understand why the if statement isn't functioning

  10. #10
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,397
    Rep Power
    25

    Default Re: Need some help with quick question

    if statement isn't functioning
    I'm sure it is.
    Add a println just after the if to show when the if condition is true by printing a message.
    If you have printed the value of the condition of the if test just before the if and it prints true then the println statement inside of the if will execute and print.

    Post the code you are using for testing and copy and post here the printouts from the debug code you have added.

Similar Threads

  1. Quick question.
    By juxta in forum New To Java
    Replies: 11
    Last Post: 12-09-2011, 03:23 AM
  2. quick question
    By biggerthanblue in forum New To Java
    Replies: 2
    Last Post: 04-10-2011, 04:33 AM
  3. Quick question
    By Thumper in forum New To Java
    Replies: 10
    Last Post: 11-07-2010, 10:06 PM
  4. Really quick question
    By shadycharacter in forum New To Java
    Replies: 2
    Last Post: 04-22-2010, 10:06 PM
  5. One last quick question
    By jigglywiggly in forum New To Java
    Replies: 7
    Last Post: 01-26-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •