C++ code to Java, few questions : <p>I got a code but it's C++ which I don't know.
But there are many similarities between C++ and Java in my opinion.
The only things I don't know what they mean / how to write them in Java are these:</p>

<pre><code>u = getNextUglyNumber(twoQ, threeQ, fiveQ, &amp;q); //and what is &amp;q, the &amp;?

twoQ.push(u &lt;&lt; 1); //what is &lt;&lt; ?

std::cout &lt;&lt; u &lt;&lt; ' '; //this i dont understand at all

*q = 2; // same as q = 2*q?

if (fiveQ.front() &lt; u) {
        u = fiveQ.front(); //whats front?
</code></pre>

<p>Thanks a lot in advance for any kind of help!</p>

<p>Here is also the full code:</p>

<pre><code>typedef std::queue&lt;int&gt; Queue;
int findNthUglyNumber(int n) {
    Queue twoQ, threeQ, fiveQ;
    twoQ.push(2);
    threeQ.push(3);
    fiveQ.push(5);
    int u, q;
    while (n) {
        u = getNextUglyNumber(twoQ, threeQ, fiveQ, &amp;q);
        switch (q) {
        case 2:
            twoQ.push(u &lt;&lt; 1);           /// u * 2
        case 3:
            threeQ.push(u &lt;&lt; 2 - u);     /// u * 3
        case 5:
            fiveQ.push(u &lt;&lt; 2 + u);      /// u * 5
        }
        n--;
        std::cout &lt;&lt; u &lt;&lt; ' ';
    }
    return u;
}

int getNextUglyNumber(Queue &amp;twoQ, Queue &amp;threeQ, Queue &amp;fiveQ, int &amp;q) {
    int u = twoQ.front();
    *q = 2;
    if (threeQ.front() &lt; u) {
        u = threeQ.front();
        *q = 3;
    }
    if (fiveQ.front() &lt; u) {
        u = fiveQ.front();
        *q = 5;
    }
    switch (*q) {
    case 2:
        twoQ.pop();
        break;
    case 3:
        threeQ.pop();
        break;
    case 5:
        fiveQ.pop();
        break;
    }
    return u;
}
</code></pre>
