Equivalent of std::vector in Java?

后端 未结 9 1246
名媛妹妹
名媛妹妹 2020-12-15 03:16

What would be the closest thing to a std::vector in Java? By this I mean, a class which can take in T into its constructor and then pushBack, popBack() and that is stored in

9条回答
  •  旧巷少年郎
    2020-12-15 03:31

    i think it is the LinkedList

    vector (c++)   <===========> linkedlist(java) 
    v.front()      <===========> l.peekFirst() 
    v.back()       <===========> l.peekLast()  
    v.push_back(x) <===========> l.add(x) 
    v.pop_back()   <===========> l.pollLast() 
    

提交回复
热议问题