Beginner- How do I call a variable in Java? : (I removed some of the code for easy reading)

The variable is already declared in the method, and I want to use the variable again, in the same method for an if else statement.This is my method and variable declared

public void update() {
       
 InvoiceDto invoiceToUpdate = invoiceService.readByCode(code);
}

How do I call this variable again to use below:
       
        InvoiceDto invoiceToUpdate = invoiceService.readByCode(code); 
        if (invoiceToUpdate == null) {
            System.out.println("Please enter a valid invoice code");