Thic code desn't pass testing. What is wrong with it?

/* Exception when operating with numbers
Catch the exception that occurs when run the code:
    int a = 42 / 0;
    Display the exception to the screen, specifying its type.
*/

public class Solution
{
    public static void main(String[] args) throws Exception
    {
        //add your code here

        try
        {
            int a = 42/0;
        }
        catch (Exception e)
        {
            //e.printStackTrace();
            System.out.println(e.getMessage());
        }

        //add your code here

    }
}

asked 05 Aug '17, 12:50

genek's gravatar image

genek
172
accept rate: 0%


instead of line

System.out.println(e.getMessage());

this works

System.out.println(e.toString() + e.getMessage());
link

answered 05 Aug '17, 14:56

genek's gravatar image

genek
172
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×40
×30
×11

Asked: 05 Aug '17, 12:50

Seen: 441 times

Last updated: 05 Aug '17, 14:56