Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the akin to C/C++ INT_MAX macro in Java

Tags:

java

Like C/C++ have the INT_MAX macro (#include<limits.h>) to set a variable to INFINITY. I was wondering if there is a similar function/macro in JAVA. I want to set an integer variable to INFINITY.

Thanks in advance !!

like image 651
Gauraang Khurana Avatar asked Nov 17 '25 22:11

Gauraang Khurana


1 Answers

The static MAX_VALUE variable of the Integer class is what you want.

Integer.MAX_VALUE

However, this isn't as useful in Java, since int values in Java are 32 bits no matter what.

Go to the following web page to learn more about the Integer class:

https://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html

like image 108
Cpp plus 1 Avatar answered Nov 19 '25 12:11

Cpp plus 1



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!