我总是记不住电话号码。我需要一个记忆规则。


当前回答

在路径上使用Groovy:

groovy -e " println Integer.MAX_VALUE "

(在Java上下文中,Groovy对于快速参考非常有用。)

其他回答

最大负值(32位):-2147483648 (1 << 31)

最大正(32位)值:2147483647 ~(1 << 31)

记忆:“醉酒又好色”

drunk ========= Drinking age is 21
AK ============ AK 47
A ============= 4 (A and 4 look the same)
horny ========= internet rule 34 (if it exists, there's 18+ material of it) 

21 47 4(years) 3(years) 4(years)
21 47 48       36       48

我能想到的最正确的答案是Int32.MaxValue。

在C语言中,在#include <stdint.h>后使用INT32_MAX。 在c++中,在#include <cstdint>后使用INT32_MAX。

或INT_MAX平台特定的大小或UINT32_MAX或UINT_MAX unsigned int。参见http://www.cplusplus.com/reference/cstdint/和http://www.cplusplus.com/reference/climits/。

或运算符(int)。

使用Java 9的REPL, jshell:

$ jshell
|  Welcome to JShell -- Version 9-Debian

jshell> System.out.println(Integer.MAX_VALUE)
2147483647

它是10位数字,所以假装它是一个电话号码(假设你在美国)。214-748-3647。我不建议调用它。