當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。