Back to questions
JuniorTheoryCommon
What happens when this program is compiled and run?
public class Main {
public static void main(String[] args) {
long big = 3_000_000_000;
System.out.println(big);
}
}It does not compile
- Expecting
3000000000: thelongon the left does not make the literal along; withoutLit is anint, and three billion does not fit. - Expecting a wrapped-around number or a run-time failure: javac rejects a literal past the
intrange withinteger number too large.
- Why does
long x = 2_000_000_000 * 2;compile but give a negative number? - Why is the
longsuffix written asLrather thanl?