Discussion Locked

comparing strings in java

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I'm retrieving a column of string datatype from the table and copy it into a string.I want to
compare that string with the string i get from the
user.It maybe a portion of the string from the table.I can't fix and index as i don't know which
portion of the string the user will enter.Can u help me in this?

3 replies

by rashmigopinath

You can use the following syntax to check for String comparison:
class myTest
{
public static void main(String[] args)
{
String s1 = "HELLO";
if (s1.equals(args[0]))
{
System.out.println("Both are equal");
}else
{
System.out.println("Both are not equal");
}
}
}

The value of s1 will have to be substituted with the String value which you obtain from the table.

This discussion is closed to new replies.