Two Laptop Bag*
The moose likes Beginning Java and the fly likes Hi check this code.It is not going in if condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Hi check this code.It is not going in if condition" Watch "Hi check this code.It is not going in if condition" New topic
Author

Hi check this code.It is not going in if condition

Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
Hi
Please check this iit is not going in if condition.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
At what point?


cmbhatt
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
The code you have posted is working fine.. Check the input, Its case Sensitive..
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707


You are comparing the String reference (using ==) not the content equality
using (equals(Object).
Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
hi
I am reading from a file .whose contents are

Problem is it is reteiving the data from the file .But when it enters the while loop .It does nt compares the string in the if condition .I have tried using compareTo() and equals() also.But it is not comparing the string s.Also after reading 2 lines the reader goes to the third line and brings a blank space . which it should not show.
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Did you use?



if you don't want use equals() do String t ="accId"; rather than
String t = new String("accId");
Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
thanks
Actually I did not trim the data coming from the file .It had space in it.
 
Don't get me started about those stupid light bulbs.
 
subject: Hi check this code.It is not going in if condition
 
Similar Threads
Whats Wrong in my Thread program
Suppressing proceeding statements after if statement fails
3 array help
Problem with Session Beans
Can anybody fix this code with above requirements.