Auf Thema antworten

ok, was ist jetzt falsch was ist jetzt richtig?

Ich habe immer neue Codes gepostet, keine geändert.


übrigens habe ich nun eine etwas andere Variante und diese Variante, wenn ich es umkehrt mache, sprich a in den Nenner setze, kommt infinity dabei raus. Der Typ ist jetzt aber double, aber das sollte ja nichts zur Sache tun oder..


das war bei


publicclass Arithmetic__exception1 nicht so


[code=Java]

public class Arithmetic__exception2 {


    public static void main(String[] args) {

   

         

          divide(0);


    }


    public static double divide(int a){

        double solution=0;

        try

        {

           solution = 1.0/a;

           System.out.println(solution);

        }

        catch (ArithmeticException e)

        {

            System.out.println("Division by null is not allowed");

            System.out.println(e.toString());

        }

        return solution;

    }


}

[/code]



Oben