本文整理汇总了Java中java.util.ArrayList.add方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.add方法的具体用法?Java ArrayList.add怎么用?Java ArrayList.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ArrayList
的用法示例。
在下文中一共展示了ArrayList.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import java.util.ArrayList; //导入方法依赖的package包/类
public void execute() throws AlgorithmExecutionException{
////////////////////////////////////////////
// THE DISCOVERY ALGORITHM LIVES HERE :-) //
////////////////////////////////////////////
input = this.inputGenerator.generateNewCopy();
this.relationName = input.relationName();
this.columnNames = input.columnNames();
ArrayList<HyperLogLog> Columns = new ArrayList<HyperLogLog>();
for (int i = 0; i < columnNames.size(); i++)
Columns.add(new HyperLogLog(eps));
while (input.hasNext()) {
List<String> CurrentTuple=input.next();
for (int i = 0; i < columnNames.size(); i++)
Columns.get(i).offer(CurrentTuple.get(i));
}
for (int i = 0; i < columnNames.size(); i++)
{addStatistic(NUMBEROFDISTINCT, Columns.get(i).cardinality(), columnNames.get(i), relationName); }
}
示例2: ArrayListDemoSection4
import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayListDemoSection4() {
int x[] = new int[4];
x[0] = 30;
x[1] = 87;
x[2] = 89;
x[3] = 33;
for (int i = 0; i < x.length; i++)
System.out.println(x[i]);
ArrayList<Integer> numbersList = new ArrayList<>();
numbersList.add(30);
numbersList.add(87);
numbersList.add(89);
for (int i = 0; i < numbersList.size(); i++)
System.out.println(numbersList.get(i));
// enhanced for loop
for (Integer num : numbersList)
System.out.println(num);
}
示例3: getPlatformVersionDependentExtraValue
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* Returns the extra value that is optimized for the running OS.
* <p>
* Historically the extra value has been used as the last resort to annotate various kinds of
* attributes. Some of these attributes are valid only on some platform versions. Thus we cannot
* assume that the extra values stored in a persistent storage are always valid. We need to
* regenerate the extra value on the fly instead.
* </p>
* @param localeString the locale string (e.g., "en_US").
* @param keyboardLayoutSetName the keyboard layout set name (e.g., "dvorak").
* @param isAsciiCapable true when ASCII characters are supported with this layout.
* @param isEmojiCapable true when Unicode Emoji characters are supported with this layout.
* @return extra value that is optimized for the running OS.
* @see #getPlatformVersionIndependentSubtypeId(String, String)
*/
private static String getPlatformVersionDependentExtraValue(final String localeString,
final String keyboardLayoutSetName, final boolean isAsciiCapable,
final boolean isEmojiCapable) {
final ArrayList<String> extraValueItems = new ArrayList<>();
extraValueItems.add(KEYBOARD_LAYOUT_SET + "=" + keyboardLayoutSetName);
if (isAsciiCapable) {
extraValueItems.add(ASCII_CAPABLE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
SubtypeLocaleUtils.isExceptionalLocale(localeString)) {
extraValueItems.add(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME + "=" +
SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(keyboardLayoutSetName));
}
if (isEmojiCapable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
extraValueItems.add(EMOJI_CAPABLE);
}
extraValueItems.add(IS_ADDITIONAL_SUBTYPE);
return TextUtils.join(",", extraValueItems);
}
示例4: setInputList
import java.util.ArrayList; //导入方法依赖的package包/类
private static void setInputList(ArrayList<String> inputList)
{
String[] id_data = null;
String line;
Scanner scan = new Scanner(System.in);
System.out.println("Enter UserId and a Date (yyyy-mm-dd) separated by a space!");
System.out.println("Enter -1 as UserId to stop");
do
{
try
{
line = scan.nextLine();
id_data = line.split(" ");
Integer.parseInt(id_data[0]);
if (!id_data[0].equals("-1") && isValideDate(id_data[1]))
inputList.add(line);
}
catch(NumberFormatException e)
{
}
}while(!id_data[0].equals("-1"));
scan.close();
}
示例5: canThisActionDistinguish
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* whether this action can remove at least one possible position
* the basic idea is the same as the howThisActionCanDistinguish method
* @param thePool, the possible position pool
* @param action, the imaged next step (0F,1B,2L,3R)
* @return double value, the number of different scenario after this action/the total number of
* scenarios after this action
*/
private boolean canThisActionDistinguish(HashSet<Position> thePool, int action) {
HashSet<Position> pool = (HashSet<Position>) thePool.clone();
// if action is not valid, return -1
ArrayList<String> results = new ArrayList<String>();
for (Position pos : pool) {
// clone the position (if we use the original one, we need to move
// it back, which I don't want to do)
Position copy = pos.clone();
// simulate the movement
copy.relativeMove(action);
results.add(getRelativeOccupiedInfo(copy));
}
double diffNum = new HashSet<String>(results).size();
return diffNum > 1;
}
示例6: getFilesOfNames
import java.util.ArrayList; //导入方法依赖的package包/类
public static ArrayList<File> getFilesOfNames(String[] names, ArrayList<File> files) {
ArrayList<File> ausgabe = new ArrayList<>();
for(File f : files) {
boolean temp = false;
for(String g : names) {
if(g.equals(f.getName())) {
temp = true;
break;
}
}
if(temp) {
ausgabe.add(f);
}
}
return ausgabe;
}
示例7: setUpSongs
import java.util.ArrayList; //导入方法依赖的package包/类
private void setUpSongs() {
songsRecyclerview.setLayoutManager(new LinearLayoutManager(getActivity()));
ArrayList<Song> songList;
songList = ArtistSongLoader.getSongsForArtist(getActivity(), artistID);
// adding one dummy song to top of arraylist
//there will be albums header at this position in recyclerview
songList.add(0, new Song(-1, -1, -1, "dummy", "dummy", "dummy", -1, -1));
mSongAdapter = new ArtistSongAdapter(getActivity(), songList, artistID);
songsRecyclerview.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST));
songsRecyclerview.setAdapter(mSongAdapter);
}
示例8: TreeDataDemo
import java.util.ArrayList; //导入方法依赖的package包/类
public TreeDataDemo() {
TreeNodeBean matt = _createNode("Matt", "male");
TreeNodeBean john = _createNode("John", "male");
TreeNodeBean ira = _createNode("Ira", "female");
TreeNodeBean tom = _createNode("Tom", "male");
TreeNodeBean jack = _createNode("Jack", "male");
TreeNodeBean victoria = _createNode("Victoria", "female");
TreeNodeBean angelina = _createNode("Angelina", "female");
TreeNodeBean mark = _createNode("Mark", "male");
TreeNodeBean kate = _createNode("Kate", "female");
TreeNodeBean lucy = _createNode("Lucy", "female");
TreeNodeBean amy = _createNode("Amy", "female");
TreeNodeBean victor = _createNode("Victor", "male");
root.add(matt);
ArrayList<TreeNodeBean> list_0 = new ArrayList<TreeNodeBean>();
list_0.add(john);
list_0.add(victoria);
list_0.add(kate);
list_0.add(lucy);
list_0.add(amy);
list_0.add(victor);
matt.setChildren(list_0);
ArrayList<TreeNodeBean> list_0_0 = new ArrayList<TreeNodeBean>();
list_0_0.add(ira);
list_0_0.add(jack);
john.setChildren(list_0_0);
ArrayList<TreeNodeBean> list_0_0_0 = new ArrayList<TreeNodeBean>();
list_0_0_0.add(tom);
ira.setChildren(list_0_0_0);
ArrayList<TreeNodeBean> list_0_1 = new ArrayList<TreeNodeBean>();
list_0_1.add(angelina);
list_0_1.add(mark);
victoria.setChildren(list_0_1);
}
示例9: subLetturaOggetti
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* subLetturaOggetti() prende quello che gli passa il metodo lettura()
* e li scrive negli attributi di un oggetto, e poi aggiunge quell'oggetto ad un
* ArrayList.
*
* @param st
* @param oggetti
*/
public void subLetturaOggetti(StringTokenizer st, ArrayList oggetti)
{
String nome = st.nextToken();
String attributo = st.nextToken();
String fileDomande = percorsoFile + st.nextToken();
String fileScelte = percorsoFile + st.nextToken();
String fileAdiacenze = percorsoFile + st.nextToken();
Oggetto o = new Oggetto(nome, attributo, fileDomande, fileScelte, fileAdiacenze);
oggetti.add(o);
}
示例10: toAspSubstanceVOCollection
import java.util.ArrayList; //导入方法依赖的package包/类
private ArrayList<AspSubstanceVO> toAspSubstanceVOCollection(Collection<AspSubstance> substances) { // lazyload persistentset prevention
// related to http://forum.andromda.org/viewtopic.php?t=4288
AspSubstanceDao aspSubstanceDao = this.getAspSubstanceDao();
ArrayList<AspSubstanceVO> result = new ArrayList<AspSubstanceVO>(substances.size());
Iterator<AspSubstance> it = substances.iterator();
while (it.hasNext()) {
result.add(aspSubstanceDao.toAspSubstanceVO(it.next()));
}
Collections.sort(result, SUBSTANCE_ID_COMPARATOR);
return result;
}
示例11: getTargetColumnArrayList
import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<Double> getTargetColumnArrayList(int i){
ArrayList<Double> result = new ArrayList<>();
for(int j=0;j<numberOfRecords;j++){
result.add(targetData.get(j).get(i));
}
return result;
}
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:8,代码来源:NeuralOutputData.java
示例12: getConfigurationRequirements
import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public ArrayList<ConfigurationRequirement<?>> getConfigurationRequirements() {
ArrayList<ConfigurationRequirement<?>> spec = new ArrayList<>();
ConfigurationRequirementRelationalInput input = new ConfigurationRequirementRelationalInput(INPUT_HANDLE);
spec.add(input);
ConfigurationRequirementBoolean nullEqualsNull = new ConfigurationRequirementBoolean(NULL_EQUALS_NULL);
Boolean[] defaultNullEqualsNull = new Boolean[1];
defaultNullEqualsNull[0] = true;
nullEqualsNull.setDefaultValues(defaultNullEqualsNull);
nullEqualsNull.setRequired(true);
spec.add(nullEqualsNull);
return spec;
}
示例13: getMoves
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* @param b Board
* @param x x location of piece
* @param y y location of piece
* @return
*/
public ArrayList<Move> getMoves(Board b, int x, int y) {
ArrayList<Move> moves = new ArrayList<Move>();
if(color == Piece.WHITE) {
// forward
if(valid(x,y+1) && !b.getTile(x, y+1).isOccupied())
moves.add(new Move(x,y,x,y+1));
// kill diagonally
if(valid(x+1,y+1) && b.getTile(x+1, y+1).isOccupied() && b.getTile(x+1, y+1).getPiece().getColor() != color)
moves.add(new Move(x,y,x+1,y+1));
// kill diagonally
if(valid(x-1,y+1) && b.getTile(x-1, y+1).isOccupied() && b.getTile(x-1, y+1).getPiece().getColor() != color)
moves.add(new Move(x,y,x-1,y+1));
}
else {
// forward
if(valid(x,y-1) && !b.getTile(x, y-1).isOccupied())
moves.add(new Move(x,y,x,y-1));
// kill diagonally
if(valid(x+1,y-1) && b.getTile(x+1, y-1).isOccupied() && b.getTile(x+1, y-1).getPiece().getColor() != color)
moves.add(new Move(x,y,x+1,y-1));
// kill diagonally
if(valid(x-1,y-1) && b.getTile(x-1, y-1).isOccupied() && b.getTile(x-1, y-1).getPiece().getColor() != color)
moves.add(new Move(x,y,x-1,y-1));
}
return moves;
}
示例14: registered
import java.util.ArrayList; //导入方法依赖的package包/类
public Symbol[] registered() throws InternalError {
ArrayList<Symbol> s = new ArrayList<Symbol>();
for (String objectName : this.list) {
//objectName = "sdc." + objectName;
s.add(this.createInstance(objectName));
}
return s.toArray(new Symbol[this.list.size()]);
}
示例15: getAllNPCsLocations
import java.util.ArrayList; //导入方法依赖的package包/类
public static ArrayList<Location> getAllNPCsLocations() {
ArrayList<Location> locations = new ArrayList<>();
for (String npc : getAllNPCs()) {
locations.add(getLocation(npc));
}
return locations;
}