7 It is the Bitwise xor operator in java which results 1 for different value of bit (ie 1 ^ 0 = 1) and 0 for same value of bit (ie 0 ^ 0 = 0) when a number is written in binary form. ex :- To use your example: The binary representation of 5 is 0101. The binary representation of 4 is 0100.
Not only in Java, this syntax is available within PHP, Objective-C too. In the following link it gives the following explanation, which is quiet good to understand it: A ternary operator is some operation operating on 3 inputs. It's a shortcut for an if-else statement, and is also known as a conditional operator. In Perl/PHP it works as:
How do the post increment (i++) and pre increment (++i) operators work in Java? Asked 15 years, 11 months ago Modified 1 year, 8 months ago Viewed 450k times
While hunting through some code I came across the arrow operator, what exactly does it do? I thought Java did not have an arrow operator. return (Collection<Car>) CollectionUtils.select(list...
In Java Persistence API you use them to map a Java class with database tables. For example @Table () Used to map the particular Java class to the date base table. @Entity Represents that the class is an entity class. Similarly you can use many annotations to map individual columns, generate ids, generate version, relationships etc.
Since java.lang.String class override equals method, It return true if two String object contains same content but == will only return true if two references are pointing to same object. Here is an example of comparing two Strings in Java for equality using == and equals() method which will clear some doubts:
The double colon, i.e., the :: operator, was introduced in Java 8 as a method reference. A method reference is a form of lambda expression which is used to reference the existing method by its name.
I always thought that && operator in Java is used for verifying whether both its boolean operands are true, and the & operator is used to do Bit-wise operations on two integer types.
12 In Java there is a difference between x++ and ++x ++x is a prefix form: It increments the variables expression then uses the new value in the expression. For example if used in code: