(Not So) Stupid Questions 7: >>, >>>, <<, and ?: operators Blog

    (Not So) Stupid Questions

    >>, >>>, <<, and ?: operators

    Editor's note: Sometimes the most interesting discussions begin when someone says, "This may be a stupid question, but .... " If the person asking the question has taken the time to think about the problem before asking, the question is often not stupid at all. The uncertainty points out an ambiguity in the specs, holes in the docs, or a search for how more experienced programmers might address a particular problem. From time to time, we will print one of the "(Not So) Stupid Questions" we receive and invite our readers to answer the question in the feedback section.

    Remember that new people are joining the Java community all the time and may be looking for help from those with more experience. Also, those who began with Java as their first language can benefit from those coming to the community with experience in other languages. As always, answer the questions with kindness. You are also welcome to submit your questions to

    This may be a stupid question, but ... "There are some weird Java operators I don't understand."

    First thoughts:

    In my development, I often use the operators for mathematical functions (+, -, *, etc.), assigning values (=), testing values (==, >, >=, etc.), and combinations of these (+=).

    But sometimes, in other people's code, I occasionally see some weird "greater than/less than" type operators like >> and <<.  I assume those aren't the mathematical "much greater than" and "much less than," but then, what are they?  There's also a "question mark" operator (?) that really isn't very self-descriptive.  What is that supposed to be telling me?

    My question is:

    What are these operators, what do they do, and why would I ever want or need to use them?