Skip to main content

This function keeps only returning F...any thoughts?

3 replies [Last post]
Balron
Offline
Joined: 2006-02-17

public static String ProcessLogin(Vector UL, String Data, int Logging)
{
String sReturn = "";
String[] sSplit = new String[4];
int i = 0;
String sTemp = "";

sSplit = SplitSaP(Data);

for(i = 0; i < UL.size(); i++)
{
if(sSplit[1] != ((UserList)UL.elementAt(i)).sUsername)
{
sReturn = "F";
}
else
{
sReturn = "S";
i = UL.size() + 1;
System.out.println("Raaar");
break;
}

if(Logging == 10)
{
System.out.println(((UserList)UL.elementAt(i)).sUsername +"=?"+ sSplit[1]);
System.out.println(sSplit[2] +"=?"+ ((UserList)UL.elementAt(i)).sPassword);
System.out.println(sReturn);
}
}
return sReturn;
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mgrev
Offline
Joined: 2003-08-12

Well just after a very quick look it looks like maybe you do a != instead of .equals() == false in the row:
[code]
if(sSplit[1] != ((UserList)UL.elementAt(i)).sUsername)
[/code]

This is a common misstake with strings and equality.

Maybe...

srotman
Offline
Joined: 2003-06-16

Well, here's a thought. You probably keep triggering the condition that sets the return value to "F".

By the way, put code tags around your code to make it a lot more readable

brinkley
Offline
Joined: 2003-06-06

This topic was moved. The JavaHelp forum is for questions on the JavaHelp API, not generalized java help questions.

Binky