Discuss / Java / 作业

作业

Topic source
public class Main {

    public static void main(String[] args) {
        String a = "12";
        String b = "x9";

        try {
            int c = stringToInt(a);
            int d = stringToInt(b);
            System.out.println(c * d);
        } catch (NumberFormatException e) {
            LoggerFactory.getLogger(Main.class).error("NumberFormatException\n" + e.getMessage());
        }
    }

    static int stringToInt(String s) throws NumberFormatException {
        return Integer.parseInt(s);
    }
}

  • 1

Reply