5 Replies Latest reply: Sep 29, 2009 6:19 AM by 800580 RSS

    transforming a string to an integer

    807580
      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.