I have this method:

public String addBuddy(String buddyName, HashMap userList)
{       
        if(buddyList.contains(buddyName))
            statusMessage = "Buddy already in list";
        else if (!userList.containsKey(buddyName))
            statusMessage = "No such user on server";            
        else
            buddyList.add(buddyName);
            statusMessage = "Buddy added";
        return (statusMessage);
    }

When I call this in my main how would i display the statusMessage? statusMessage is declared so that's not the problem

In my main I'm calling:

if (option == 3)
           {
               System.out.println("enter user name: ");
               String buddyName = a.nextLine();
               server.userList.get(user).addBuddy(buddyName, server.userList);
           }

Thanks for the help

System.out.println(addBuddy(buddyName, server.userList));
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.