This discussion is archived
5 Replies Latest reply: Sep 29, 2009 4:19 AM by 800580 RSS

transforming a string to an integer

807580 Newbie
Currently Being Moderated
I have the following code and I am trying to convert a string to an integer:
import java.util.*;
public class Switcheroo
{
 static  Scanner console = new Scanner(System.in);
  
  public static void main(String[] args)
  {
  String employee = console.next();
  
  int n;
  if (employee == "buckwheat")
  {
    n = 1;
  }
  else
  {
    n = 2;
  }
  
  System.out.println(n);
  
 
  }
}
When I type buckwheat this evaluates to 2. What gives?

Thanks for any help.