Equality of strings


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Equality of strings

  1. #1
    Join Date
    Oct 2004
    Posts
    21

    Equality of strings

    Hi,
    I have two strings that I think are the same. One is in an array list and the other is in an array.
    Heres what they look like:
    String[] names = new String[l];
    ArrayList<String> v = new ArrayList<String>();
    If I print them out like:
    System.out.print(v.get(l+1) + " " + names[i]);
    they both show dave
    but if i do
    if(names[i] == v.get(l+1))
    the if statement returns false, (this is in a for statement)

    Anyone know why this could be happening?
    Thanks.

  2. #2
    Join Date
    Oct 2004
    Posts
    12
    http://java.sun.com/j2se/1.4.2/docs/...ng/String.html

    if(names[i].equals(v.get(l+1)) {statement;}

  3. #3
    Join Date
    Oct 2004
    Posts
    12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center