Java: Size of vector in bytes

Java: Size of vector in bytes … here is a solution to the problem.

Java: Size of vector in bytes

Is it possible to get the size of a Vector or ArrayList or any object in bytes in java? The size() function only gives the number of elements. But I want to get the actual size of the object.

Solution

Currently, I have achieved my own size.

long sizeof(ArrayList<String> list)
{
    long size = 0;
    for(String s: list)
        size+=s.length();
    return size;
}

Related Problems and Solutions