Returning string from method help

Reply

Join Date: Jul 2008
Posts: 2
Reputation: Nbutz is an unknown quantity at this point 
Solved Threads: 0
Nbutz Nbutz is offline Offline
Newbie Poster

Returning string from method help

 
0
  #1
Nov 12th, 2008
I have this method:
  1.  
  2. public String addBuddy(String buddyName, HashMap userList)
  3. {
  4. if(buddyList.contains(buddyName))
  5. statusMessage = "Buddy already in list";
  6. else if (!userList.containsKey(buddyName))
  7. statusMessage = "No such user on server";
  8. else
  9. buddyList.add(buddyName);
  10. statusMessage = "Buddy added";
  11. return (statusMessage);
  12. }

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:

  1. if (option == 3)
  2. {
  3. System.out.println("enter user name: ");
  4. String buddyName = a.nextLine();
  5. server.userList.get(user).addBuddy(buddyName, server.userList);
  6. }
Thanks for the help
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,158
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 136
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Returning string from method help

 
0
  #2
Nov 12th, 2008
  1. System.out.println(addBuddy(buddyName, server.userList));
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC