Kafka , Java - what does this "_" represent in integer literal

Viewed 99

I come across the following syntax to represent an integer and it looks new to me. What does it signify

props.put(ProducerConfig.BATCH_SIZE_CONFIG, 16_384 * 4);

How does 16384 is different from 16_384 ?

2 Answers

It's the same. You can use "_" on an integer to make it be more readable.

16_384 is more readable than 16384

16_384_000 is more readable than 16384000

In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal. This feature enables you, for example, to separate groups of digits in numeric literals, which can improve the readability of your code.

long creditCardNumber = 1234_5678_9012_3456L; long socialSecurityNumber = 999_99_9999L;

Related