Results 1 to 6 of 6

Thread: if statement

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2002
    Posts
    118

    if statement

    Hi all,

    I am having problem with a simple If statement:

    if(Value>0.0)
    {
    stack.push(Pj);
    stack.push(Pi);
    stack.push(Pt);
    }
    else
    stack.push(convex.get(i));

    Value is greater(double) then 0.0. After it goes "if statement", it continues to goes through "else". Event though the Value is greater than 0.0.

    Thanks!

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: if statement

    Is this exactly the code you have in your .java file? Can you copy & paste a bit from the source, with a little more context?
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3
    Junior Member
    Join Date
    Nov 2006
    Posts
    24

    Re: if statement

    Code:
     if(Value>0.0)
     {
           stack.push('Pj');
           stack.push('Pi');
           stack.push('Pt');
     }
     else
             stack.push(convex.get('i'));
    Try that maybe...But yes, the whole code. Or at least the part that deals with this would be help full.

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: if statement

    GhettoT, how is that any different?

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594

    Re: if statement

    It's invalid, for a start. You can't (or at least really, really shouldn't - not sure in Java) put single qoutes around more than one character, unless it's an escape sequence.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  6. #6
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Re: if statement

    Quote Originally Posted by AlnavPlatinum
    Hi all,

    I am having problem with a simple If statement:

    if(Value>0.0)
    {
    stack.push(Pj);
    stack.push(Pi);
    stack.push(Pt);
    }
    else
    stack.push(convex.get(i));

    Value is greater(double) then 0.0. After it goes "if statement", it continues to goes through "else". Event though the Value is greater than 0.0.

    Thanks!
    Are you sure stack.push(convex.get(i)); doesn't just have the same value as stack.push(Pj); or stack.push(Pi); or stack.push(Pt); ?


    To test whether it really is going through both the if statement and else statement:

    Code:
     if(Value>0.0)
     {
           stack.push(Pj);
           stack.push(Pi);
           stack.push(Pt);
           System.out.println("IF STATEMENT");
     }
     else
    {
            stack.push(convex.get(i)); 
           System.out.println("ELSE STATEMENT");
    }

Posting Permissions

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



Click Here to Expand Forum to Full Width