当前位置: 首页>>代码示例>>Java>>正文


Java ArrayList.add方法代码示例

本文整理汇总了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); }
   
}
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:27,代码来源:DVHyperLogLogAlgorithm.java

示例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);
}
 
开发者ID:kmhasan-class,项目名称:spring2017java,代码行数:21,代码来源:ArrayListDemoSection4.java

示例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);
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:35,代码来源:AdditionalSubtypeUtils.java

示例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();
  }
 
开发者ID:collab-uniba,项目名称:SO_reputation,代码行数:26,代码来源:Main.java

示例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;
}
 
开发者ID:JINKEHE,项目名称:Rescue-Victims,代码行数:24,代码来源:Playground.java

示例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;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:17,代码来源:JUtils.java

示例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);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:15,代码来源:ArtistMusicFragment.java

示例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);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:39,代码来源:NavigationTreeBean.java

示例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);
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-I,代码行数:20,代码来源:LetturaOggetti.java

示例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;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:12,代码来源:AspDaoImpl.java

示例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;
 }
 
开发者ID:HPI-Information-Systems,项目名称:metanome-algorithms,代码行数:16,代码来源:Ducc.java

示例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;
}
 
开发者ID:codeekage,项目名称:java-chess,代码行数:39,代码来源:Pawn.java

示例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()]);
   }
 
开发者ID:BlidiWajdi,项目名称:Mujeed-Arabic-Prolog,代码行数:11,代码来源:Factory.java

示例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;
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:8,代码来源:MerchantManager.java


注:本文中的java.util.ArrayList.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。