Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help creating multiple return statements in a java methood
    primarykey
    data
    text
    <p>I'm a freshmen at college and I'm starting with my first Java programming course. The professor sent us an assignment in order to make an application simulating the database of the USPS.</p> <p>Anyways, I got to the point where I want my program to ask line by line for the recipients information (address, name, city etc) and I managed to do so using a simple JOptionPane. The problem is that now, I'm using Java methods and I can't for the life of me figure out how to make the return statement so my program moves on to the next method, with my recipients information.</p> <pre><code>private static String getString(String string) { // TODO Auto-generated method stub String nameString = JOptionPane.showInputDialog(null, "Recipients name:", "Certified Mail Receipt", 3); String streetAddressString = JOptionPane.showInputDialog(null, "Street, Apt. No. or P.O. Box No.:", "Certified Mail Receipt", 3); String cityString = JOptionPane.showInputDialog(null, "City, State, Zip Code", "Certified Mail Receipt", 3); // return ?????????` } </code></pre> <p>The compiler will only let me insert one return statement and only one of the 3 questions gets sent to the next methood. I think I need a way to get the three things in a return statement so the program stops asking the same recipients information questions over and over again.</p> <p>I'm using the Eclipse Java compiler if that helps. Thanks!</p> <p>======================EDIT================================ @TerryLi helped me by finding an error in my class</p> <pre><code>private static String getString(String type) { String result = JOptionPane.showInputDialog(null, type, "Certified Mail Receipt", 3); return result; </code></pre> <p>}</p> <p>This is how I manged to get it to work. again thanks to @terryli and everyone who helped out with a reply!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload