• Saves Valuable Time
  • Trusted Accuracy since 2004
  • 15-Day Money-Back Guarantee

C++ Equivalent to Java ArrayList

The nearly exact C++ equivalent to Java's ArrayList collection is the std::vector collection.

Java C++
void ArrayList()
{
    java.util.ArrayList<Integer> myList = new java.util.ArrayList<Integer>();
    myList.add(1);
    int i = 1;
    myList.set(0, i);
    i = myList.get(0);
}
#include <vector>

virtual void ArrayList()
{
    std::vector<int> myList;
    myList.push_back(1);
    int i = 1;
    myList[0] = i;
    i = myList[0];
}


Use Java to C++ Converter to convert from Java to C++.     

Additional resource: Java and C++ Equivalents


Copyright © 2004 – 2019 Tangible Software Solutions, Inc.