I am up with my new puzzle today. Just go through the code below and see if you can guess the output. The code looks pretty simple. But beware, its not that easy:
public class StringPuzzle {
public static void main(String[] args) {
final String a = "length is 12";
final String b = "length is " + a.length();
System.out.println("Strings are equal: " + a == b);
}
}
Well... can you guess the answer? Ok... let me read your mind... you guessed the output Strings are equal: true or you might have guessed Strings are equal: false.
Well I have some bad news for you. In both the cases you are incorrect. Isn't it strange! Don't believe my words. Just execute this program and you will see it yourself.
Post a solution in comment section. Happy coding!!
5 comments:
+ binds before == therefore the answer was false.
nice one.
Hi Arpit!
sorry to comment here.. but I was trying your application of ContactDemoApplication....of developing a demo application on netbeans.. I m using netbeans 6.8 with glassfish v3... everything is workin fine.. but on running the app. i m not getting the list of contacts added instead I m getting "Result = [org.webservices.client.Contact@2bc61a, org.webservices.client.Contact@1dad926, org.webservices.client.Contact@e6882f, org.webservices.client.Contact@f6f23b]"
Please help me ASAP..plz u can mail me as well...ravi.iiitm06@gmail.com
good catch!!
Post a Comment