Results 1 to 5 of 5

Thread: Easy task

  1. #1
    Srcee is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    0

    Default Easy task

    I need the following code written with if:

    n = ( n.left != null ) ? n.left : n.right;

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,371
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Srcee View Post
    I need the following code written with if:

    n = ( n.left != null ) ? n.left : n.right;
    You already wrote it; what else do you want? An if statement can of course do it but note that it is a statement, not an expression as you have now:

    Java Code:
    if (n.left != null)
       n= n.left;
    else
       n= n.right;
    kind regards,

    Jos

  3. #3
    Srcee is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    You already wrote it; what else do you want? An if statement can of course do it but note that it is a statement, not an expression as you have now:

    Java Code:
    if (n.left != null)
       n= n.left;
    else
       n= n.right;
    kind regards,

    Jos
    Tnx a lot. It really helped me. You can delete the thread now

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Srcee View Post
    ...You can delete the thread now
    Why do you wish it deleted?

  5. #5
    Srcee is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    Why do you wish it deleted?
    I don't know, I thought it makes the forum crowded.

Similar Threads

  1. Brutos an easy to use web MVC.
    By plic_ploc in forum Java Software
    Replies: 2
    Last Post: 11-07-2012, 02:05 AM
  2. how easy it is?
    By ron87 in forum New To Java
    Replies: 0
    Last Post: 04-01-2009, 06:36 PM
  3. Not so easy is it.
    By Roy Gardiner in forum Introductions
    Replies: 0
    Last Post: 10-24-2008, 04:59 PM
  4. What does this mean (Very Easy)
    By Zebra in forum New To Java
    Replies: 6
    Last Post: 05-01-2008, 01:46 PM
  5. Easy question
    By JavaNoob in forum New To Java
    Replies: 10
    Last Post: 08-03-2007, 10:28 PM

Posting Permissions

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