top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Which Java operator is right associative?

+2 votes
909 views
Which Java operator is right associative?
posted Apr 21, 2016 by Ramesh Gowda

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes

Almost all arithmetic operators are left associative. This includes addition, multiplication, subtraction, and division.
Even so, it's good to know what right associativity is.

Here's the rule: if all operators have the same precedence and are right associative, then pick the rightmost uncovered operator to parenthesize.

For example, suppose Java had a $ operator (it doesn't, but pretend that it does), and you wanted to parenthesize a $ b $ c $ d $ e using right associativity.

Prefix Unary operators
Object creation and cast
Ternary
Assignment

answer Apr 25, 2016 by Karthick.c
+2 votes

Here is the list of some right associative operators in java:
1.Prefix Unary operators
2.Object creation and cast
3.Ternary
4. Assignment

Reference : http://www.geekinterview.com/question_details/63

answer Apr 26, 2016 by Shivam Kumar Pandey
Thanks for the link
Similar Questions
0 votes

Which one will be faster in Java, Increment operator or Decrement operator?

a) for(int i = 0; i < 1000; i++) {}    
b) for(int i = 1000; i > 0; i--) {}
0 votes

I am search for different approach.
Let see how many solution i can get

...