| | |
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,160
Reputation:
Solved Threads: 137
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 |
actuate android api applet application applications array arrays automation balls bank binary bluetooth bold business c++ chat class clear client code codesnippet collections component coordinates database defaultmethod development dice doctype dragging ebook eclipse educational error file formatingtextintooltipjava fractal froglogic game givemetehcodez graphics gui hql html ide ideas image infinite ingres integer intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans newbie openjavafx parameter php problem program programming project recursion repositories scanner scrollbar sell server set sms sort sorting sql sqlserver state storm string sun superclass swing swt threads tree websites windows






