Vector和Stack
import java.util.*;
public class Test1 {
public static void main(String[] args){
Vector cc=new Vector();
Sp sp1=new Sp("001","巧克力",20f);
Sp sp2=new Sp("002","果脯",10f);
cc.add(sp1);
cc.add(sp2);
for(int i=0;i<cc.size();i++){
System.out.println(((Sp)cc.get(i)).getMingcheng());
}
System.out.println();
Stack dd=new Stack();
Sp sp3=new Sp("001","香蕉",20f);
Sp sp4=new Sp("002","蘋果",10f);
dd.add(sp3);
dd.add(sp4);
for(int i=0;i<cc.size();i++){
System.out.println(((Sp)dd.get(i)).getMingcheng());
}
}
}
class Sp{
private String bianhao;
private String mingcheng;
private float jiage;
Sp(String bianhao,String mingcheng,float jiage){
this.bianhao=bianhao;
this.mingcheng=mingcheng;
this.jiage=jiage;
}
public String getBianhao() {
return bianhao;
}
public void setBianhao(String bianhao) {
this.bianhao = bianhao;
}
public String getMingcheng() {
return mingcheng;
}
public void setMingcheng(String mingcheng) {
this.mingcheng = mingcheng;
}
public float getJiage() {
return jiage;
}
public void setJiage(float jiage) {
this.jiage = jiage;
}
}
相關文章
- java基礎:Vector/Stack — 原始碼分析Java原始碼
- Java常用資料結構之Stack&VectorJava資料結構
- map和set對vector排序排序
- C++【vector】用法和例子C++
- std::vector 和 std::list 區別
- 太極1:STL:vector和string
- Pandas 基礎 (12) - Stack 和 Unstack
- C++【stack/queue】用法和例子C++
- 【譯】Rust中的array、vector和sliceRust
- Flutter控制元件--Row、Column和StackFlutter控制元件
- Java中Vector和ArrayList的區別Java
- vector
- stack
- STACK!
- Vector底層結構和程式碼解析
- LinkedList和ArrayList的區別、Vector和ArrayList的區別
- Tech Stack
- java stackJava
- Stack類
- Stack (stl)
- stack overflow
- 使用Java和Elastic Stack進行日誌分析JavaAST
- 【資料結構】棧(Stack)和佇列(Queue)資料結構佇列
- Vector人工智慧情感機器人SDK釋出和說明(ROS2GO 2.0 + Vector 2.0)人工智慧機器人ROSGo
- C++筆記— 排序函式sort() 和vector容器C++筆記排序函式
- c++ vector容器——檢測更改容量和大小 示例C++
- java複習之 Vector、ArrayList和LinkedList 的區別Java
- Paimon Deletion VectorAI
- c++ vectorC++
- Vector擴容
- vector——C++C++
- STL容器---Vector
- LeetCode Min StackLeetCode
- Support Vector MachinesMac
- vector 使用 上
- 使用 Bro IDS 和 Intel Critical Stack 分析網路活動Intel
- Javascript是如何工作的: Engine, Runtime 和 Call Stack的概述JavaScript
- row_vector and col_vector的建立 (Leetcode 807, Leetcode 531)LeetCode