4.8. Command Line Input

Generally, arguments are sent to programs run on the command line by simply typing them after the name of the program you're about to run. The program will likely expect them in a certain order. For instance, think of modifying the DebtApp program to accept debt, expenses, and income values: the program will expect the values in a certain order. We could modify the program to accept first income, then expenses, then debt. Instead of hardcoding these values inside the program, which requires you to retype inside the code (which could be dangerous), and then recompile the program (which takes time), you could pass them in as arguments. Here is how we had it written inside the DebtApp class:

 ... // initialize vars income ...

Get Java™ for ColdFusion® Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.