In an exercise in my book, I've come across an example that doesn't go too far into explaining a section of the code. I don't know what it's called so I'm having a tough time finding it. Here's a clip of it, what I've highlighted in bold and underlined is what's got me stumped...
public class Sales2 { public static void main( String[] args ) { Scanner input = new Scanner( System.in ); // sales array holds data on number of each product sold // by each salesperson double[][] sales = new double[ 5 ][ 4 ]; System.out.print( "Enter salesperson number (-1 to end): " ); int person = input.nextInt(); while ( person != -1 ) { System.out.print( "Enter product number: " ); // int product = input.nextInt(); System.out.print( "Enter sales amount: " ); double amount = input.nextDouble(); // error-check the input if ( person >= 1 && person < 5 && product >= 1 && product < 6 && amount >= 0 ) [B][U][SIZE="3"] sales[ product - 1 ][ person - 1 ] += amount;[/SIZE][/U][/B] else System.out.println( "Invalid input!" ); System.out.print( "Enter salesperson number (-1 to end): " ); person = input.nextInt(); }
Any idea what "sales[ product - 1 ][ person - 1 ] += amount;" is doing? Because I don't, I'm stumped. Anyone know what it is called at the very least?