3 Replies Latest reply: Feb 2, 2007 7:22 AM by 796254 RSS

    found java.lang.String but expected boolean ?

    807599
      I get this compile error at the end here. Can someone help out.
      import java.util.HashMap;
      import java.util.Scanner;
      import java.util.Set;
      /**
       * Write a description of class PhoneBook here.
       * 
       * @author (your name) 
       * @version (a version number or a date)
       */
      public class PhoneBook
      {
           private HashMap<String, String> phonebook;
           private InputReader reader;
      
           /**
            * Constructor for objects of class PhoneBook
            */
           public PhoneBook()
           {
                phonebook = new HashMap<String, String>();
                reader = new InputReader();
                
           }
      
           /**
            * Add single entry to the phonebook
            */
           public void addSingleEntry(String name, String phoneNo)
           {
                phonebook.put(name, phoneNo);
           }
      
           /**
            * Find a name in the phonebook
            */
           public void findName(String name)
           {
               String phoneNo = phonebook.get(name);        
               if(phoneNo = null) 
               {
                   System.out.println("No phone Number");
                  } else {
                      System.out.println("Phone Num is " + phoneNo);
                  }
              }
      }
      
      i get that error on the line 'if(phoneNo = null)'