Meaning of >, >>, >>> in Java

Source: Internet
Author: User
Tags pow

In Java :

> represents greater than, for example: if (a>b) ... The result is a Boolean type

>> to move right, such as: int i=15; The result of the I>>2 is 3, and the removed part will be discarded.

The conversion to binary may be better understood, 0000 1111 (15) The result of the right shift 2 bits is 0000 0011 (3), 0001 1010 (18) The result of the right shift 3 bits is 0000 0011 (3).

I'm not very clear about what >>> is called, but I know what it means:

The results of J>>>i and j/(int) (Math.pow (2,i)) are the same, where I and J are shaped.

The test code is as follows:

  1. Public class Test
  2. {
  3. Public static void Main (string[] args)
  4. {
  5. System.out.println ("1, the following test;:");
  6. int a = 1, b = 2;
  7. System.out.println (a > B);
  8. System.out.println ("\n2, the following test >>:");
  9. System.out.println (">> 2 =" + (>> 2));
  10. System.out.println ("\n3, the following test >>>:");
  11. for (int i = 0; i < ; i++)
  12. {
  13. for (int j = 0; j < k ; j = j + 5)
  14. {
  15. System.out.println (J/(int) (Math.pow (2, I)));
  16. System.out.println (J >>> i);
  17. }
  18. }
  19. }
  20. }

Meaning of >, >>, >>> in Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.