How to represent infinity in Java

2 Answers

0 votes
package javaapplication1;
 
public class Example {
    public static void main(String[] args) {

        double inf;
        
        inf = Double.POSITIVE_INFINITY;
	
        System.out.println(inf);
    }
}
 
/*
run:
  
Infinity
  
*/

 



answered Apr 3, 2016 by avibootz
0 votes
package javaapplication1;
 
public class Example {
    public static void main(String[] args) {

        double inf;
        
        inf = Double.NEGATIVE_INFINITY;
	
        System.out.println(inf);
    }
}
 
/*
run:
  
-Infinity
  
*/

 



answered Apr 3, 2016 by avibootz

Related questions

1 answer 210 views
1 answer 177 views
2 answers 266 views
266 views asked Apr 2, 2016 by avibootz
2 answers 225 views
225 views asked Apr 2, 2016 by avibootz
2 answers 190 views
190 views asked Sep 9, 2016 by avibootz
1 answer 166 views
166 views asked Apr 3, 2016 by avibootz
...