Solution 24 строка. Подскажите, плиз, что не так )
Если быть точнее, то
неизвестная ошибка компиляции
ioexception is never thrown in body of corresponding try statement
package com.javarush.task.task15.task1522;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Закрепляем паттерн Singleton
*/
public class Solution {
public static void main(String[] args) {
}
public static Planet thePlanet;
//add static block here - добавьте статический блок тут
static {
try {
readKeyFromConsoleAndInitPlanet();
}
catch (IOException e) {
e.printStackTrace();
}
}
public static void readKeyFromConsoleAndInitPlanet() {
// implement step #5 here - реализуйте задание №5 тут
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String s;
if ((s = br.readLine()).equals(Planet.EARTH)) {
thePlanet = (Planet) Earth.getInstance();
}
if (s.equals(Planet.MOON)) {
thePlanet = (Planet) Moon.getInstance();
}
if (s.equals(Planet.SUN)) {
thePlanet = (Planet) Sun.getInstance();
}
} catch (Exception e) {
thePlanet = null;
}
br.close();
}
}