Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the array I have: 

var arr1 = ['a1', 'a2', 'a3', 'a4', 'a5'];

I can do a left shift by 2 on it. Can anyone tell me how to perform the right shift by 2 on the array?

1 Answer

0 votes
by (19.7k points)

You do shift right on N positions and shift left on array.length - N positions. If you want to shift right by 2, you need to shift the array by 3 on the left position.  

 If you want to learn more about Javathen go through this Java tutorial by Intellipaat for more insights.

Related questions

0 votes
1 answer
asked May 15, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
1 answer
asked Apr 28, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer

Browse Categories

...