scg/ch10/ArgumentCharacters

From FANG

Jump to: navigation, search

01 package scg.ch10;
02 
03 import java.util.ArrayList;
04 
05 import fang2.core.Game;
06 import fang2.util.InitializeApplication;
07 
08 /**
09  * Read unnamed arguments, print out the first argument one character
10  * per line. Demonstrates how a String is a collection of char.
11  */
12 public class ArgumentCharacters
13   extends Game {
14   /**
15    * If there are any unnamed command-line parameters, then get the
16    * first one and print out the characters, one per line. If there are
17    * no parameters, print out a message to that effect.
18    */
19   @Override
20   public void setup() {
21     System.out.println(getClass().getName());
22     ArrayList<String> args = InitializeApplication.getUnnamedArgs();
23     if (args.isEmpty()) {
24       System.out.println("  No unnamed argument provided");
25     } else {
26       String firstArgument = args.get(0);
27       for (int = 0; i != firstArgument.length()++i{
28         System.out.println("  str.charAt(" + i + ") = '" +
29           firstArgument.charAt(i+ "'");
30       }
31     }
32   }
33 }
34 
35 //Uploaded on Mon Mar 29 21:42:26 EDT 2010


Download/View scg/ch10/ArgumentCharacters.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter

Games
Games