Results 1 to 6 of 6

Thread: equals sign

  1. #1
    therealyacek is offline Member
    Join Date
    Oct 2012
    Posts
    8
    Rep Power
    0

    Question equals sign

    Are this:
    Java Code:
    tail.next = newNode;
    tail = newNode;
    and this
    Java Code:
    tail.next = tail = newNode;
    the same thing?

  2. #2
    Reeling is offline Member
    Join Date
    Jan 2012
    Posts
    49
    Rep Power
    0

    Default Re: equals sign

    why not put that in to an IDE and test it?

  3. #3
    therealyacek is offline Member
    Join Date
    Oct 2012
    Posts
    8
    Rep Power
    0

    Default Re: equals sign

    I will test it once I finish all my methods in my class since my class implements an interface and I can't compile it right now until I have all the classes done...
    was just wondering before hand so I could clean up my code some.

  4. #4
    Reeling is offline Member
    Join Date
    Jan 2012
    Posts
    49
    Rep Power
    0

    Default Re: equals sign

    create a new file and compile it.

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

    Default Re: equals sign

    No, they're not the same thing.

    Proof: (without compiler) The first is a couple of straight forward assignments. It is clear what it does.

    The second isn't clear. It even makes the author stop and wonder.

    Therefore they aren't the same.

    ---

    Of course, they may (or may not) do exactly the same thing. They may (or may not) be functionally equivalent and generate the same byte code. To figure that one out, Reeling has the right idea.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: equals sign

    Quote Originally Posted by therealyacek View Post
    I will test it once I finish all my methods in my class
    Bad approach, and expecially so for a beginner. Make the habit of compiling every time you add a few lines. That way you don't end up with an overwhelming amount of compiler errors, and for the one or two you might experience, you know exactly where to look: the code you've just written.

    If your problem is that an interface is yet to be implemented, you have some options to allow you to compile:
    -- add an empty implementation, or one that throws UnsupportedOperationException
    -- temporarily declare the class abstract
    -- temporarily comment out the implements clause

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Single Sign on
    By iksaak in forum Advanced Java
    Replies: 0
    Last Post: 07-06-2010, 08:36 AM
  2. the @sign
    By dinosoep in forum New To Java
    Replies: 2
    Last Post: 03-28-2010, 11:07 AM
  3. sign finder
    By iPetey in forum New To Java
    Replies: 6
    Last Post: 05-01-2009, 05:24 AM
  4. How To self sign applet
    By Chintan Patel in forum Java Applets
    Replies: 1
    Last Post: 03-16-2009, 02:31 PM
  5. Replies: 0
    Last Post: 01-25-2008, 11:13 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
  •