> ## Content Index
> Fetch the complete content index at: https://www.narendravardi.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Java Shot #4: Writing readable long numbers in Java
- URL: https://www.narendravardi.com/java-shot-4-writing-readable-long-numbers-in-java/
- Published: 2024-09-20T10:30:17.000Z
- Updated: 2024-12-02T08:42:43.000Z
- Author: Narendra Vardi
- Tags: java-shot

If you are someone who works with Long numbers and BigIntegers, then you can make use of these two tricks to make these Long and BigIntegers more readable. 

### Avoid using lower case `l` and use upper case `L` to represent a Long value. 

```Java
public class LongTest {
  public static void main(String[] args) {
    
    // 'l' resembles '1' in certain fonts, 
    // making this confusing
    var a = 1000l; 

    // Using 'L' makes the number more readable
    var b = 1000L;
  }
}

```

Code showing the significance of using 'L' over 'l'

### Did you know that you can use `_` in numbers in Java?

```
public class IntTest {
  public static void main (String args[]) {
  
    // Tell me, is this a one lakh or 10 lakhs
    var a = 100000; 
    
    // Now answer the same question. 
    var b = 1_00_000;
  }
}
```

Code showing the significance of using '\_' to enhance readability and avoid errors.