How to find number of days between two dates using Apex?

Integer noOfDays = startDate.daysBetween(endDate);

The above formula is used to find number of days between two dates.
 
Execute the below code in Developer Console to view the output:
 
Date startDate = Date.today();
Date endDate = Date.today().addDays( 90 );
Integer noOfDays = startDate.daysBetween( endDate );
system.debug( 'Output is ' + noOfDays );