I've the following code:
public class Operators {
public static void main(String[] args) {
int i =+ 2;
System.out.println(i);
}
}
Upon executing I'm getting the following output: 2
So what does =+
operator actually does here?
EDIT:
As some answered, it is assigning +2
to i
, consider the following code:
public class Operators {
public static void main(String[] args) {
int i =- -2;
System.out.println(i);
}
}
So in above case, output should be -2
. But I'm getting 2
So I suppose, it is -(-2)
, which gives 2
. Right?