| | |
Returning string from method help
![]() |
•
•
Join Date: Jul 2008
Posts: 2
Reputation:
Solved Threads: 0
I have this method:
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:
Thanks for the help
Java Syntax (Toggle Plain Text)
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:
Java Syntax (Toggle Plain Text)
if (option == 3) { System.out.println("enter user name: "); String buddyName = a.nextLine(); server.userList.get(user).addBuddy(buddyName, server.userList); }
•
•
Join Date: Aug 2008
Posts: 1,158
Reputation:
Solved Threads: 136
Java Syntax (Toggle Plain Text)
System.out.println(addBuddy(buddyName, server.userList));
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
- Need some help with a trivial dll/string method. (C#)
- toString format help (Java)
- Returning Empty Datatable (ASP.NET)
- Simply question: How do I return a string from a function (C)
- Parsing a String (Java)
- Returning & (Java)
- Class Passing and Returning Arrays (Java)
Other Threads in the Java Forum
- Previous Thread: Write Lists to Text File
- Next Thread: What's the most efficent way to randomize a Queue?
| Thread Tools | Search this Thread |
-xlint actionlistener add android applet application array automation bank bi binary blackberry block bluetooth character class client code compile compiler component consumer database desktop developmenthelp eclipse equation error event fractal ftp functiontesting game gameprogramming givemetehcodez graphics gui health html hyper idea image infinite int j2me j2seprojects java javac javaee javame javaprojects jetbrains jni jpanel jtable julia learningresources lego linked linux mac main method mobile myregfun netbeans notdisplaying number online pearl printf problem program qt researchinmotion rotatetext rsa scanner screen server set singleton sms sort spamblocker sql string swing system textfields thread threads time title tree tutorial-sample update variablebinding windows xor






