String line = null;
double value;
BufferedReader in = new BufferedReader(new FileReader("C:\Users\Bilal\Documents\Work\scrambler\input.txt"));

int x=0;
while (line != "end"){


    line = in.readLine();
    System.out.println(line); 

    x++;
}

}}

When I run this.. the loop does not stop when the word end comes.. why???????

Always, always, always use equals() for comparison between the texts of Strings. == is only used for checking if a String is null or not.

String s1 = "Hello!";
String s2 = "Hi!";
//s1 might '==' s2, but !s1.equals(s2).

Hope that makes sense!

Thnaks for your resonse ..

Exception in thread "main" java.lang.NullPointerException
at test.main(test.java:26)

im getting this erron now??

nvm.. all is well thax a ton!!

String s1 = "Hello!";
String s2 = "Hi!";
// s1 might '==' s2, but !s1.equals(s2).

No, in that example s1 cannot == s2.
The == tests for s1 referring to exactly the same object as s2, whereas equals tests for two Strings containing the same sequence of letters.
If s1 == s2 then by definition s1.equals(s2) and s2.equals(s1)
But if s1.equals(s2) then it does not imply that s1==s2 because they may refer to two different String objects that just happen to contain identical sequences of letters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.