can i return two values from a return method?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
can i return two values from a return method?
No. The return statement can only specify one value to be returned.
If you don't understand my answer, don't ignore it, ask a question.
A method can return only one value of one type. But it can be an object (with more properties) or an array (with more elements).
But apart this, you should clarify why and for what you need to return two values. Are they related? (e.g. the min and max of something) Do you think it has sense that these two values be modeled with an object?
Andrea, www.andbin.net — SCJP 5 (91%) – SCWCD 5 (94%)
Useful links for Java beginners – My new project Java Examples on Google Code
Please create an object then save all informations into its instance and return it.
Always read, always write, can not stop learning! I'm willing to answer your question.