0

Good afternoon,

When I compile this code:

public class HelloWorld {

  public static void main(String[] args) throws Exception {

    AnimalFactory factory = new AnimalFactory();

    System.out.println("C:\\springboot\\Third\\src\\test\\resources\\fileTest.txt");

    Path path = Paths.get("C:\\springboot\\Third\\src\\test\\resources\\fileTest.txt");

    String read = Files.readAllLines(path).get(0);

    System.out.println(read);

      Animal anm = factory.create(AnimalType.DONKEY);
      System.out.println(anm.makeSound());
      System.out.println("I am here!!");
      System.out.println(1/0);

    System.out.println(CurrencyType.KWD.getDecimalPoints());
    System.out.println(CurrencyType.USD.getIsoCurrencyCode());

  }
}

I got Hello ! Hello ! Hello ! Exception in thread "main"

Why I got this? and how can I solve it?

Thanks in advance

Federico klez Culloca
  • 24,336
  • 15
  • 57
  • 93
  • why are you dividing by 0 ?? – Antoniossss May 30 '22 at 11:04
  • And where exactly do you get the exception? – Noltibus May 30 '22 at 11:05
  • 1
    There is a lot of stuff in this code which is completely opaque to us. For example i *suppose* that `Hello ! Hello ! Hello !` comes from inside the file? And I *suppose* the exception comes either from inside `factory.create(...)` or from `anm.makeSound()` but you didn't show us what's in there and you didn't show a stack trace either, so we can just guess. – Federico klez Culloca May 30 '22 at 11:06

0 Answers0