• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Neha Kathuriaa
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Please check this iit is not going in if condition.
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At what point?
 
Meet Gaurav
Ranch Hand
Posts: 492
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you have posted is working fine.. Check the input, Its case Sensitive..
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You are comparing the String reference (using ==) not the content equality
using (equals(Object).
 
Neha Kathuriaa
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you use?



if you don't want use equals() do String t ="accId"; rather than
String t = new String("accId");
 
Neha Kathuriaa
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
Actually I did not trim the data coming from the file .It had space in it.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic