3

When I tried searching this I would just get things on equality.

When I was reading through some documentation for navigation in Android I had come across something I had never seen before. I came across this:

mTitle = mDrawerTitle = getTitle();

It almost looks like something you can do in JavaScript where you can take the first not-null variable and assign it to a variable.

In JavaScript I would do this:

mTitle = mDrawerTitle || getTitle();

And it would return the first not null, in Java, is this double equals usage the equivalent in Java?

What is this type of expression called?

FabianCook
  • 217
  • 1
  • 9

1 Answers1

3

Looking more into it, it is actually nothing like what I thought it was, it is simply the assignment operator.

As I found here: http://www.rapidprogramming.com/tutorial/JAVA-Operators-Logical-Conditional-Assignment--28

You can assign a value to more then one variable at once using it.

For example:

int num = 20000;

int p, q, r, s;

p = q = r = s = num;

(Taken from the site)

FabianCook
  • 217
  • 1
  • 9
  • You can assign a value to more then one variable at once because the value of an assignment is the value that was assigned. Therefore you can use the value of an assignment as a rvalue of another assignment and so on. – MrSmith42 Oct 28 '13 at 11:01