Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-03-2007, 10:44 AM
Java Tip's Avatar
Moderator
 
Join Date: Nov 2007
Posts: 1,691
Rep Power: 5
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Default Comparing Strings
String objects belong to real class String and should be compared using equals and not using ==. == will compare the references only.

Code:
String s1 = "Java String 1";
String s2 = "Java String 2";

if(s1.equals(s2))
   System.out.println("Strings are equal.");
else
   System.out.println("Strings are not equal.");
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing Images shaungoater Advanced Java 0 03-17-2008 11:38 AM
JSTL -- Comparing two strings for equality trinkets JavaServer Pages (JSP) and JSTL 0 02-12-2008 05:39 PM
Comparing dates Java Tip Java Tips 0 01-28-2008 10:02 AM
comparing Feng New To Java 2 11-23-2007 10:40 AM
Comparing JavaWebFrameworks pegitha Web Frameworks 1 05-18-2007 07:23 PM


All times are GMT +2. The time now is 08:23 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org