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 302 views
1 answer 263 views
2 answers 360 views
360 views asked Apr 2, 2016 by avibootz
2 answers 343 views
343 views asked Apr 2, 2016 by avibootz
2 answers 301 views
301 views asked Sep 9, 2016 by avibootz
1 answer 266 views
266 views asked Apr 3, 2016 by avibootz
...