inbuilt function to empty stack in java code example Example: size of stack in c++ std::stack<int> st; std::cout << "size of stack: " << st.size();