Apr 29, 2016

Go Language For Java Developer Part-6 : Operators


Operators in Java and Go Lang.  Every programming languages support operators. Operators are work like a function with different syntax compared to normal function. For example arithmetic operator +.

List of Operators in Java & Go Lang

The Following table has a list of operators available in the language.

Sr
Operator
Description
Go
Java
1
+
addition
Yes
Yes
2
-
subtraction
Yes
Yes
3
*
multiplication
Yes
Yes
4
/
quotient
Yes
Yes
5
%
remainder
Yes
Yes
6
&
bitwise and
Yes
Yes
7
|
bitwise or
Yes
Yes
8
^
bitwise xor
Yes
Yes
9
~
bitwise compliment

Yes
10
&^
bit clear (and not)
Yes

11
<<
left shift
Yes
Yes
12
>>
right shift
Yes
Yes
13
>>>
zero fill right shift

Yes
14
++
Increment

Yes
15
Decrement

Yes
16
=
equal
Yes
Yes
17
==
equal to

Yes
18
!=
not equal
Yes
Yes
19
<
less than
Yes
Yes
20
<=
less than or equal
Yes
Yes
21
>
greater than
Yes
Yes
22
>=
greater than or equal
Yes
Yes
23
&&
logical and
Yes
Yes
24
||
logical or
Yes
Yes
25
!
logical not
Yes
Yes
26
&
address of / create pointer
Yes

27
*
dereference pointer
Yes

28
<-
send / receive operator (see 'Channels' below)
Yes

29
+=
assignment Operators

Yes
30
-=
assignment Operators

Yes
31
*=
assignment Operators

Yes
32
/=
assignment Operators

Yes
33
%=
assignment Operators

Yes
34
<<=
assignment Operators

Yes
35
>>=
assignment Operators

Yes
36
&=
assignment Operators

Yes
37
^=
assignment Operators

Yes
38
|=
assignment Operators

Yes
39
?:
conditional operator

Yes

Go language doesn't have assignment operator (+=) but Go lang has & operator which works as bitwise operator and address of the pointer. Go lang has bit clear &^ operator while Java has bit shift operators.

Reference:
1. Go Lang :https://golang.org/ref/spec#Operators
2. Java Language: https://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.12

continue reading Go Language For Java Developer Part-6 : Operators