Showing posts from May, 2018

Identifiers in GO

Introduction: Identifiers in any language are name of variable, function, array, struct etc. The same applicable for GO. There are certain rule and convention for identifier in GO. Rules: 1. Identifier should start with letters or underscore. 2. It can contain numbers but it should not be at the start. Number can place in middle or end of identifier. 3. Identifier are case sensitive. It means variables result and Result are two different variables. 4. Go keywords can not be used as identifier. Go has 25 reserved keywords: 5. Go has some predefined identifier. These are not reserved. You can use them in your program. It sounds weird but all basic datatypes are also predefined datatypes, you can use them as variable name in-fact as all identifiers. Below are the list of predefined identifiers: package main import ("fmt") //import "time" func main() { var int int =10 fmt.Println(int+2) } Even though it is allowed, I personally recommend that

divide by zero in Java

You might be thinking,  divide by zero will throw ArithmeticException. But this is not true for floating point numbers. Divide by zero throws ArithmeticException only when char or integral value are divided by 0. Below two operation throws exception 10/0 'A'/0 If floating point number is divided by 0, output will be Infinity . 10.2/0 -10.3/0 Output: Infinity -Infinity