- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Integer.rotateLeft() method in Java
The Integer.rotateLeft() method returns the value obtained by rotating the two's complement binary representation of the specified int value i left by the specified number of bits. The following is the syntax.
int rotateLeft(int i, int distance)
Here are the parameters.
- i − This is the int value.
- distance − This is the rotation distance.
Example
public class Demo { public static void main(String []args) { int val = 1; for (int i = 0; i < 4; i++) { val = Integer.rotateLeft(val, 1); System.out.println(val); } } }
Output
2 4 8 16
Advertisements