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 204 views
1 answer 172 views
2 answers 259 views
259 views asked Apr 2, 2016 by avibootz
2 answers 219 views
219 views asked Apr 2, 2016 by avibootz
2 answers 186 views
186 views asked Sep 9, 2016 by avibootz
1 answer 159 views
159 views asked Apr 3, 2016 by avibootz
...