compare strings

I am trying to make a textbased game to practise for example loops.

Could someone please show me how to compare Strings. This is what I have so far:

class KeyPad

{

publicstaticvoid main(String[] args)

{

BufferedReader br =new BufferedReader(new InputStreamReader(System.in));

String s =new String() ;

String n =new String("north") ;

try

{

s = br.readLine();

if(s == n)

{

System.out.println ("so you want to go north!") ;

}

else

{

System.out.println ("Why didn't you type north?") ;

}

}

catch(Exception e)

{

System.out.println("lol");

}

}

}

[1516 byte] By [106498a] at [2007-10-3 4:06:43]
# 1
You must NOT compare Strings using string1 == string2.Use string1.equals(string2) instead.The reason for this, is that Strings are objects not primitives so when you compare via == the result depends on them being the same object, not having the same content.
TimRyanNZa at 2007-7-14 22:06:13 > top of Java-index,Java Essentials,New To Java...
# 2
You're a legend!Finally I can start my game!Thanks
106498a at 2007-7-14 22:06:13 > top of Java-index,Java Essentials,New To Java...
# 3
Does anyone also know how to make my program restart itselfe.g not close down after i type something and it replies
106498a at 2007-7-14 22:06:13 > top of Java-index,Java Essentials,New To Java...
# 4
Use a loop structure such as for or while.
TimRyanNZa at 2007-7-14 22:06:13 > top of Java-index,Java Essentials,New To Java...