The Student Room Group
Reply 1
Same way as you would call any other method.
Reply 2
you see that's my problem. i don't really know what you write to call a method!
Reply 3
Can you call main? I had a vague feeling that you couldn't. (If you can, it'll just be a case of typing main() if you're not supplying any arguments to it via the command line).

Personally I'd just do it by having the whole program running in a while(true) loop, and if the user types N at the prompt, calling System.exit(0), and doing nothing if they type Y, and letting the loop start again at the top.
Reply 4
That's not working for me :frown: I'm getting a headache.
Reply 5
OK its fixed now. thanks alex. your solution worked! i just had a number of different loops, and brackets in the wrong places.
Reply 6
alex-hs
Can you call main? I had a vague feeling that you couldn't. (If you can, it'll just be a case of typing main() if you're not supplying any arguments to it via the command line).

Personally I'd just do it by having the whole program running in a while(true) loop, and if the user types N at the prompt, calling System.exit(0), and doing nothing if they type Y, and letting the loop start again at the top.


yea this is the normal way of doing it. when ever the exit method is called (or directly change var) runs the current loop then finishes

Latest

Trending

Trending