Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By pbrockway2

Thread: Dead Code

  1. #1
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default Dead Code

    Hi all,

    Few days back I start to work on with Eclipse too (for different purposes with Java). Last night I have notice something. Look at the following code.


    Java Code:
            if (Double.NaN == Double.NaN) {
                System.out.println("True");
            } 
            else {
                System.out.println("False");
            }
    In if condition IDE notify that it is 'Dead Code'. That's all. No more explanation (if I have configured my IDE properly). I feel that newbie really confused with this in case. What you all think.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Dead Code

    In general flagging dead code is very helpful. What I think is rather surprising is that the if block is marked as dead code rather than the else block.

    Anyone confused by this just needs to be pointed in the direction of JLS 15.21.1 and helped to get over it.
    Eranga likes this.

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default Re: Dead Code

    Some sort of such explanation is really useful, and really valued.

    I waiting to test the same code by a newbie and give us a comment if possible.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

    Default Re: Dead Code

    Quote Originally Posted by pbrockway2 View Post
    Anyone confused by this just needs to be pointed in the direction of JLS 15.21.1 and helped to get over it.
    Thanks for the link mate.

Similar Threads

  1. Replies: 3
    Last Post: 08-10-2011, 09:17 AM
  2. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  3. why this simple java application goes into dead lock?
    By jokop in forum Threads and Synchronization
    Replies: 12
    Last Post: 02-04-2011, 08:57 AM
  4. Dead threads
    By Onra in forum New To Java
    Replies: 2
    Last Post: 12-19-2010, 01:26 PM
  5. Restarting dead threads
    By DC200 in forum Threads and Synchronization
    Replies: 3
    Last Post: 12-03-2010, 10:09 PM

Tags for this Thread

Posting Permissions

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