Why Boxing Is Preferred Over Var-args
Oct 26, 2014
I know from JLS that widening is preferred over boxing and boxing is preferred over var-args.
I understand that, widening is legacy methodology and designers tend to keep it as a priority. What i fail to understand is why boxing is preferred over var-args. Here are my two concerns.
Why boxing is preferred over var-args?How behind the scenes boxing and var-args is interpreted? How are var-args interpreted by the compiler? Is some sort of Array formed behind the scenes?
View Replies
Feb 5, 2015
I am trying to create a slightly modified cash register. The user will enter the amount of the item, the payment received, calculate the change/refund, and then allow the user to choose the preferred bills.
import java.util.Scanner;
public class Register {
private static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
System.out.println("*****CASH REGISTER*****" );
System.out.print("Item Amount: " );
int amount = input.nextInt();
[Code] ....
I will try to clarify the code, to make things a little easier to interpret. in the refund method, I have set up a 2-d array to exist and function as an excel sheet. The refund amount is passed to the method and compared to each bill of the array. Once the refund is determined to be greater than a bill, the user is prompted to enter the preferred bill type. This is where my problem is...I would like the program to then calculate the number of bills and keep a tally of those bills in the 2nd column and then determine the new refund amount at which point the user will be prompted again to determine the desired bill.
Then print out the array of bills that are not equal to 0.
View Replies
View Related