2

The behavior of Java is explained in this topic.

But, is Infinity useful for something?

Float:

public class DivisionByZeroFloat{
    public static void main(String[] args) {
        System.out.println(1.0 / 0);
    }
}

Console: Infinity

Integer

public class DivisionByZeroInteger {
    public static void main(String[] args) {
        System.out.println(1 / 0);
    }
}

Console: Exception in thread "main" java.lang.ArithmeticException: / by zero at DivisionByZeroInteger.main(DivisionByZeroInteger.java:4)

closed as off-topic by gnat, Greg Burghardt, Bart van Ingen Schenau, amon, Robert Harvey Oct 15 '18 at 19:19

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking for assistance in explaining, writing or debugging code are off-topic here. These can be asked on Stack Overflow if they include the desired behavior, a specific problem or error, and the shortest code necessary to reproduce it in the question (see Minimal, Complete, and Verifiable Example)." – Bart van Ingen Schenau, amon, Robert Harvey
If this question can be reworded to fit the rules in the help center, please edit the question.