Software Development

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.
 
 
 
 

SrOperatorDescriptionGoJava
1+additionYesYes
2subtractionYesYes
3*multiplicationYesYes
4/quotientYesYes
5%remainderYesYes
6&bitwise andYesYes
7|bitwise orYesYes
8^bitwise xorYesYes
9~bitwise complimentYes
10&^bit clear (and not)Yes
11<<left shiftYesYes
12>>right shiftYesYes
13>>>zero fill right shiftYes
14++IncrementYes
15DecrementYes
16=equalYesYes
17==equal toYes
18!=not equalYesYes
19<less thanYesYes
20<=less than or equalYesYes
21>greater thanYesYes
22>=greater than or equalYesYes
23&&logical andYesYes
24||logical orYesYes
25!logical notYesYes
26&address of / create pointerYes
27*dereference pointerYes
28<-send / receive operator (see ‘Channels’ below)Yes
29+=assignment OperatorsYes
30-=assignment OperatorsYes
31*=assignment OperatorsYes
32/=assignment OperatorsYes
33%=assignment OperatorsYes
34<<=assignment OperatorsYes
35>>=assignment OperatorsYes
36&=assignment OperatorsYes
37^=assignment OperatorsYes
38|=assignment OperatorsYes
39?:conditional operatorYes

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

Reference: Go Language For Java Developer Part-6 : Operators from our JCG partner Ketan Parmar at the KP Bird blog.

Ketan Parmar

Ketan Parmar (aka KPBird) is software engineer with 7 years experience, He is passionate about Java (SE,EE,ME),Android,BlackBerry, Grid Computing, Big Data, UI/UX and Open Source
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button