Search:

Type: Posts; User: Norm

Search: Search took 0.10 seconds.

  1. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    If an array is defined inside of a method, it can be passed as an arg to another method that is called from that method:

    void aMethod() {
    int[] anArray = {1}; // define an array in this...
  2. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    Sorry I don't understand your question.
    An array can hold many values.

    What do you want the method to do?
  3. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    The code still has the recursive call. That should be removed and a loop used instead.
  4. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    That is probably because of the recursive call:

    studentNumberEntered(number, sc);

    Use a loop instead of a recursive call.
  5. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    Put the code in a while() loop that continues looping UNTIL the user enters the desired input.
  6. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    Put the code that causes the exception inside a try{}catch block. The catch block code will get control if an exception is thrown.
  7. Replies
    20
    Views
    1,760

    Re: Rejecting certain inputs

    I don't know any way to stop a user from entering whatever he wants. The program can refuse to accept what is entered and ask the user to enter what the program wants. This can be done repeatedly...
Results 1 to 7 of 7