HTML

Difference between var, val, and def in Scala

This is one of the frequently asked questions from Scala interviews. Even though both var and val keyword is used to declare variables in Scala there is a subtle difference between them. A var is a variable. It’s a mutable reference to a value. Since it’s mutable, its value may change through the program lifetime. On the other hand, val keyword represents a value. It’s an immutable reference, meaning that its value never changes. Once assigned it will always keep the same value. It’s similar to a final variable in Java or constants in other languages. It's also worth to remember that the variable type cannot change in Scala. You may say that a var behaves similarly to Java variables.

Top 5 Books Java 8 Certifications - 1Z0-808 (OCA) and 1Z0-809 (OCP)

In order to become a Java 8 Certified developer, you need to pass two exams, the OCAJP 8 exam with code 1Z0-808 and the OCPJP8 exam with code 1Z0-809. You will not be a Java SE 8 certified programmer if you just pass the OCAJP8 exam. In order to prepare for both these exams, you need to choose a good study guide and a good mock exam simulator, apart from writing programs on daily basis. Since there are a lot of demand for Java 8 certified professionals across the world, it seems to be a good opportunity to change your career path by learning Java 8, if you are doing some boring IT work and wants to become an application developer. The Java certifications will provide you both knowledge and competitive edge over other candidates who are applying for same Java developer job.

Top 10 Free Python Programming Books - Download PDF or Read Online

Every Programmer loves free eBook, even more, if it comes from renowned technical book publishers like Oreilly or Manning. In the last article, I have shared some of the best free Java programming books and today I am going to share some of the equally best free Python Programming books. These books are not illegal copies which are uploaded into the internet, but they are the legal copies, made free by their author and publishers. Though these are not full-fledged books but concise eBooks, they are very informative and comprehensive enough to learn things like Data Science and Functional programming in Python.

How to convert JSON String to Java Object - Gson/JSON Deserialization Example

In the last article, you have learned how to convert a Java object to JSON String and in today's article, you will learn the opposite, i.e. converting a JSON String to Java object. The first example was known as JSON serialization example and this one is known as JSON deserialization because we are creating a Java object from a String. The idea is very similar to classical Serialization in Java where you convert a Java object to another binary format which can be transported over the network or can be saved in the disk for further usage. That's why the process of converting a Java object to JSON is known as serialization and converting a JSON document to Java object is known as De-Serialization. You can use any JSON library to perform serialization and de-serialization e.g. Jackson Databind, Gson, or Json-simple.  In this program, I'll show you how to use Gson to create a Java object from given JSON String.

How to convert Java object to JSON String - Gson Java/JSON Serialization Example

If you are a Java or Android developer and learning JSON to support JSON format for your project and looking for a quick and simple way to convert your Java object into json format then you have come to the right place. In this article, I'll teach you how to convert a Java object to JSON document using Google's Java library called Gson. This library allows you to convert both Java object to JSON String and a JSON document to Java object. So, let's first do some serialization. Serialization in the context of Gson means mapping a Java object to its JSON representation. In the real world, the data can be really complex with lots of attributes and nested with composed object but for now, we'll start with a class which just contain few value attributes e.g. String, int and boolean.