Dividing by zero for double value - Java Language Basics

Java examples for Language Basics:double

Introduction

Special Constants of the float and double Classes

Constant Meaning
POSITIVE_INFINITYPositive infinity
NEGATIVE_INFINITYNegative infinity
NaN Not a number

Demo Code

public class Main {
  public static void main(String[] args) {
    double i = 50.0;
    double j = 0.0;
    double k = i / j;
    System.out.println(k);//from w  ww.  jav  a2 s  .co m

    i = -50.0;
    k = i / j;
    System.out.println(k);


    i = 0.0;
    k = i / j;
    System.out.println(k);
  }

}

Related Tutorials