Slashdot Mirror


User: rabbitsushi

rabbitsushi's activity in the archive.

Stories
0
Comments
2
First seen
Last seen
Profile
(view on slashdot.org)

Comments · 2

  1. Re:Another reason I can avoid Java on Q&A With James Gosling, Father of Java · · Score: 1

    Yeah, how about:

    public class IdMain
    {
            public IdMain(){
                    go();
                    }

            private void go()
            {
                    String strLitName = "Patrick Naughton";
                    String strObjName = new String("Patrick Naughton");

                    if(strLitName == "Patrick Naughton"){
                            System.out.println("== evaluated to true");
                    }
                    else{
                            System.out.println("== evaluated to false");
                    }
                    if(strObjName == "Patrick Naughton"){
                            System.out.println("== evaluated to true");
                    }
                    else{
                            System.out.println("== evaluated to false");
                    }
            }
                    public static void main(String[] args) {
                            new IdMain();
                    }
    }

  2. Re:Another reason I can avoid Java on Q&A With James Gosling, Father of Java · · Score: 1

    Actually, that really depends what suspect has been initialized to.. If suspect has been assigned a String literal (as opposed to a new String object), the == operator works just fine. :)