List_Queue_Compared2
Objective :

In this example I used C++ compiler to compare, List with Queue compiled in java

Script:
#include <iostream>
#include <queue>
#include <list>
using namespace std;
//
void collectionlist()
{
    string str1[] = {"A", "C","B","D","E"};
    cout<<("List ArrayList Print out")<<endl;
    list<string>::iterator it;
    list<string> list1 (str1, str1+5);
    queue<string> Q1;
    cout<< "List " <<endl;
    for(it = list1.begin(); it !=list1.end(); it++)
    {
        //list1.add(st1);// accessing list with an index
        cout<<( *it);   cout<<(" || ");
        Q1.push(*it);
    }// for loop ends
    cout<<endl;      cout<< "Queue " <<endl;
while(!Q1.empty())
{
   cout<< Q1.front();
    cout<<(" || ");
   Q1.pop();
}
 cout<<endl;//
}

			
int main()
{
    cout<<" Calling a function  collectionlist() "<<endl;
    collectionlist();
    cout << "Hello World!" << endl;
    return 0;
}

		

Runtime View