Results 1 to 8 of 8
Thread: Introduction & A Quick Big Doubt
- 12-28-2010, 07:49 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
Introduction & A Quick Big Doubt
Dear All,
I am new here, i have started learning java directly just since over a week, i got my interest in Java from knowing about applications and things "My Name is James Joseph" and please find below a sample code, i need you guys advice on!
Now the problem is, how do i change it to String the bind function ? and get its response? for a newbie to java this is too big of an advanced problem! would take any positive and negative advice ) i tried a lot but the whole app would give errors :(Java Code:public void bind() { debug.enter(this, "SMPP.bind()"); try { if (bound) { this.unbind(); return; } BindRequest request = null; BindResponse response = null; String syncMode = "a";// (asynchronous ? "a" : "s"); // type of the session syncMode = "a";//getParam("Asynchronous/Synchronnous Session? (a/s)", syncMode); asynchronous = false; // input values bindOption = "t";// getParam("Transmitter/Receiver/Transciever (t/r/tr)", bindOption); request = new BindTransciever(); ipAddress = ipAddress; port = port; TCPIPConnection connection = new TCPIPConnection(ipAddress, port); connection.setReceiveTimeout(20 * 1000); session = new Session(connection); systemId = systemId; password = password; // set values request.setSystemId(systemId); request.setPassword(password); request.setSystemType(systemType); request.setInterfaceVersion((byte) 0x34); request.setAddressRange(addressRange); // send the request System.out.println("Bind request " + request.debugString()); if (asynchronous) { pduListener = new SMPPTestPDUEventListener(session); response = session.bind(request, pduListener); } else { response = session.bind(request); } logger.info("Bind response " + response.debugString()); if (response.getCommandStatus() == Data.ESME_ROK) { bound = true; } } catch (Exception e) { event.write(e, ""); debug.write("Bind operation failed. " + e); System.out.println("Bind operation failed. " + e); // return "Error-" + e.getMessage(); } finally { debug.exit(this); } }
- 12-28-2010, 08:55 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
I don't think I undestand your question; do you want your method to return a (String) value? (the Java jargon is 'method', not 'function' but they are equivalent). Or do you want to pass parameters to your method? Note that a method can return a (a single) value of any type.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-28-2010, 09:03 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
Dear JosAh,
Exactly what you mentioned "I want this method to return a string" :)
Thanks for the response...
- 12-28-2010, 09:20 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-28-2010, 09:23 AM #5
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
- 12-28-2010, 09:44 AM #6
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
The compiler issues that error message when it finds a path in the execution of your method body that doesn't result in a 'return someStringValue;'. Your method was declared to return a String so it always should do so; this is a simple example where the method doesn't always return a String:
Suppose a <= b, so the body of the if statement isn't executed and nothing is returned by the method. The compiler whines about it.Java Code:public String bind() { if (a > b) return "foo"; }
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-28-2010, 09:58 AM #7
Member
- Join Date
- Dec 2010
- Posts
- 4
- Rep Power
- 0
Jos, i will study this and get back to you on how i succeed at fixing it... :) with your advice...
Thanks a ton :)
- 12-28-2010, 10:09 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,427
- Blog Entries
- 7
- Rep Power
- 17
You're welcome of course; Java's compiler messages are as clear as they come, all you have to learn is how to interpret those messages. You'll learn how to do that by making mistakes, reading what the compiler has to say about it and (most important), why the compiler issued the message. Assuming that your code is correct is extremely dangerous and most of the time simply incorrect ;-)
kind regards,
JWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Introduction
By goldhouse in forum LuceneReplies: 2Last Post: 01-17-2010, 12:56 PM -
introduction
By Rooneyz in forum IntroductionsReplies: 4Last Post: 08-11-2008, 02:14 PM -
Introduction
By priyasajesh in forum IntroductionsReplies: 4Last Post: 07-30-2008, 01:30 AM -
introduction
By khalandar in forum IntroductionsReplies: 4Last Post: 07-09-2008, 07:48 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks