Search:

Type: Posts; User: helloworld922

Search: Search took 0.11 seconds.

  1. Re: How to make an error message when my program crashes?

    Scanner reader = new Scanner(System.in);
    System.out.println("ram available: ");
    int ram = 0;
    try
    {
    ram = Integer.parseInt(reader.next());
    }
    catch(Exception e)
    {
    ...
  2. Re: How to make an error message when my program crashes?

    Two solutions:

    If you are using Integer.parseInt(string), then it will automatically detect this problem and throw an exception. All you have to do is catch it and display the message.

    try
    {
    ...
Results 1 to 2 of 2