Java Reference
In-Depth Information
stocks.remove("GOOG");
}
System.out.println("First screen: " + stocks);
StockScreener.screen(stocks, Screen.YIELD, 3.5);
System.out.println("Second screen: " + stocks);
StockScreener.screen(stocks, Screen.PE, 22);
System.out.println("Third screen: " + stocks);
System.out.println("Buy List: " + stocks);
}
}
The output from running this code will vary because it is randomly assigning a
stock's screen result value. Here is one sample of output from running the class:
Screening stocks: [ORCL, AAPL, GOOG, IBM, MCD]
GOOG: BETA = 1.9545048754918146
First screen: [ORCL, AAPL, IBM, MCD]
ORCL: YIELD = 5.54002319921808
AAPL: YIELD = 5.282200818124754
IBM: YIELD = 3.189521157557543
MCD: YIELD = 3.978628208965815
Second screen: [ORCL, AAPL, MCD]
ORCL: PE = 3.5561302619951993
AAPL: PE = 13.578302484429233
MCD: PE = 23.504349376296886
Third screen: [ORCL, AAPL]
Buy List: [ORCL, AAPL]
How It Works
The ArrayList is one of the most often used classes in the Java Collections Frame-
work. The ArrayList class implements the List interface, which, in turn, imple-
ments the Collection interface. The Collection interface defines the set of
common operations for all Collection types, and the List interface defines the set
of operations that are specific to the list-oriented Collection types. The Collections
Framework makes heavy use of Java generics. If you are new to generics, it is recom-
Search WWH ::




Custom Search