• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java help. (New Question)

DAM

Diamond Member
Question #2

i have some textFields, how do i setText to them? i know how to set a Int and a String, but is there a way to set a double? thanks.


Question #1 Answered
I have a *.dat file with words, and i want to check if a certain word is in that file. both variables are Strings, yet when i do

if (word == findWord)
messageBox ("match found&quot😉;


it never passes the if statement. I know it has something to do with the value of the variables, anyone know what i can do to check if a certain word is equal to another word?







thanks


dam(grrrr)
 
Whenever you're dealing with strings in Java shouldn't you use the string1.equals(string2) in place of the string1 == string2 syntax? Try that...it could help.

-GL
 
GL: ive tried that yet it always shows are true,


i did;

if (word.equals(findWord))
messageBox("Match Found&quot😉;


yet it always gives me a messaga box even when word != findWord.


what am i doing wrong???



dam🙂--( )
 
Can you provide the source for the offending code (just the part that reads in the file and includes this conditional statement)? It's difficult to diagnose, but like you said, it's pretty obvious that the problem lies in the values of word and findWord - so it's unlikely the problem lies in the code you posted here.

-GL
 
well, for now, do this:

if(string1.equals(string2))
{
system.out.println(string1 + " and " + string2 + " are the same&quot😉;
// just to make sure something is not wrong with that boolean outcome
// and you are actually comparing the right stuffs
}
else
{
system.out.println(string1 + " and " + string2 + " are NOT the same&quot😉;
}
 
doh, well, Mday's code did the trick, beats the hell out of me what i was doing wrong. thanks for all your help, i am sure that ill have more questions soon, so i hope you will all be able to aid me then.






dam(cheese)
 
Back
Top