Skip to content

Instantly share code, notes, and snippets.

@ProZhar
Created December 4, 2015 08:56
Show Gist options
  • Select an option

  • Save ProZhar/19fec2d81ce087f256d3 to your computer and use it in GitHub Desktop.

Select an option

Save ProZhar/19fec2d81ce087f256d3 to your computer and use it in GitHub Desktop.
com.javarush.test.level09.lesson06.task04
package com.javarush.test.level09.lesson06.task04;
import java.util.ArrayList;
/* Исключение при работе с коллекциями List
Перехватить исключение (и вывести его на экран), указав его тип, возникающее при выполнении кода:
ArrayList<String> list = new ArrayList<String>();
String s = list.get(18);
*/
public class Solution
{
public static void main(String[] args) throws Exception
{
try
{
ArrayList<String> list = new ArrayList<String>();
String s = list.get(18);
}
catch (Exception e)
{
System.out.println(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment