/images/profile.jpg

Okay Aslan

Technologist with years of hands-on software development, architecture and leadership experience.

Converting Types in Go

While programming, we often need type conversions. If you come from a language that usually does implicit conversions, converting types in Go can be a bit of a hassle.

First of all, let’s start with some basics. Go is a statically and strongly typed programming language. This means that, variable types must be known at compile time. Additionally, type conversions must be made explicitly.

Autoboxing and Unboxing in Java

In java, we often need to convert primitive types to their object(boxed wrappers) counterparts or vice versa. Unfortunately, doing these conversions all the time is tedious and make code verbose. For this reason, Java 1.5 introduced two concepts, autoboxing and unboxing, that automate these conversions.

Autoboxing: It is the process of converting primitives to their corresponding object type automatically.

Unboxing: It is the process of converting object types to their corresponding primitives automatically.

Argument passing in Java

Argument passing in Java is simple but sometimes confusing. Let’s go over some concepts briefly before diving into it.

If you come from a C/C++ programming background, you’ve probably heard of the “Call By Value” and “Call By Reference” argument passing concepts.

Briefly,

  • Call by Value : A copy of the object instance is passed to called method. Any modifications made on the object inside the method will not be reflected back to the original object.
  • Call by Reference : A reference to  the original object is passed to called function. This reference may be thought as an alias for the original object and any modification done on the alias object inside the method actually done on the original object.