Good day. Solved the learning task
public class Solution { public static StatelessBean BEAN = new StatelessBean(); public static void main(String[] args) throws FileSystemException { try { processExceptions(); } catch (FileSystemException f) { BEAN.log(f); } } public static void processExceptions() throws FileSystemException { try { BEAN.methodThrowExceptions(); } catch (FileSystemException f) { BEAN.log(f); throw f; } catch (CharConversionException c) { BEAN.log(c); } catch (IOException i) { BEAN.log(i); } } public static class StatelessBean { public void log(Exception exception) { System.out.println(exception.getMessage() + ", " + exception.getClass().getSimpleName()); } public void methodThrowExceptions() throws CharConversionException, FileSystemException, IOException { int i = (int) (Math.random() * 3); if (i == 0) throw new CharConversionException(); if (i == 1) throw new FileSystemException(""); if (i == 2) throw new IOException(); } } } The task was not accepted due to the fact that the signature of the main() method does not need to specify the class of the throws FileSystemException thrown into it. Please explain why you can not do this.
throws FileSystemExceptionfrom themainnot necessary, because the method does not throw it. - zRrr