Skip to main content

Favour Numberscores

When dealing with numbers above 6 digits, it can be difficult to quickly comprehend the figure they represent. By favouring underscores in our Java declarations they become far more readable.

public final class TestNumberDefinitions {

public static int NORMAL_MILLION = 1000000;
public static int FORMATTED_MILLION = 1_000_000;

public static long NORMAL_BILLION = 1000000000;
public static long FORMATTED_BILLION = 1_000_000_000;

public static long NORMAL_TRILLION = 1000000000000;
public static long FORMATTED_TRILLION = 1_000_000_000_000;

This can also be utilised for standardised formats such as credit card numbers in your test cases.

public static long CREDIT_CARD_NUMBER = 0000_1111_2222_3333_4444;
public static int SORT_CODE = 12_34_56;