Sunday, May 28, 2017

The integer literal does not conform to the expected type String

Hi Guys ,

There are multiple reasons for getting this error .

1. If you have a class for which you are trying to create an object and you have missed to specify any of the class variables while creating the object, you might face the exception like :
The boolean literal does not conform to the expected type String .

Take a look at the program below :

class Student(
    val name: String,
    var age: Int
)

fun main(args: Array<String>) {
    val student= Student(1)
    println(student.name)
    println(student.age)
}


If you try to run the above program you might face an error like .
Click here to run this test.



Friday, May 26, 2017

Java vs. Kotlin

Hi Guys,
There are a lot of difference in how a java program and kotlin program.
1. package
2.import
Java program by default imports java.lang.* package.

Thursday, May 25, 2017

Kotlin Hello World

Let's check out a simple kotlin program to print hello world to the console.
Let's check out a simple kotlin program to print hello world to the console.
Here's the program to print hello world to the console.

package demo
fun main(args : Array<String>){
println("hello world")
}
If you run the above program you will get the following output.
hello world
Now let's go the program and try to understand the way it works.
Its way more simple for developers with java background,and I strongly recommend get hands on java experience to get expertise on kotlin.
The program starts with package deceleration , which is optional. If you do not declare the package the file goes to the default package . You have few restrictions for the package name . You cannot name package as java , this is same for the programs written in java language. But kotlin is different from java , you can actually name your package as kotlin .

Tuesday, April 4, 2017

Sorting Algorithms

Hi Guys,

This blog is about the various algorithm used to sort a collection .
Let's have a look into each of these available algorithms.

1. Selection Sort
This is the easiest logic to sort a group of objects .You need to pick the smallest element and swap it with the element at first position. Now you have the first element sorted . Just repeat the same step for the remaining elements and your objects will be sorted . Easy.

2.Bubble Sort
Logic  In an array of N number , start with comparing the first two numbers . Move the lowest element up. Now take the next two numbers , compare and move the lowest of them up. Similarly proceed till the last element . Iteration one is over and we have the largest element at the bottom. Now, make N-1 iterations each time reducing the array by excluding the last element.

3.Insertion Sort
Logic  In an array of N numbers take first two numbers and sort it. This will be the sorted subset . Now, take the next number and compare it with the sorted subset and position it so that..

4.Heap Sort
Logic : Take the array of N numbers and arrange it in form of Complete Binary Tree .After that take the first element and swap it with the element at last index. Form completely Binary tree with the elements excluding the one at the first index. Continue this process until all elements are sorted .

Saturday, July 30, 2016

HAX kernel module is not installed

Hi Guys,
You might have seen this error message when you try to run for application in Android Developer Studio . There can be several reasons for this .
1. You have not installed Intel x86 emulator Accelerator .
Solution : Go to android Sdk Manager and check the option   Intel x86 emulator Accelerator . Android Developer Studio will download it to your Skd path . Go to your SDK Path and install it .

2. Virtualization is disabled in your BIOS setting .
Solution : If you get the same error after solution 1.  Go to BIOS menu and enable Hardware Virtualization .

3. Microsoft-Hyper-V is enabled 
Solution : You need to disble Microsoft-Hyper-V if it is enabled .

Monday, July 25, 2016

org.hibernate.exception.SQLGrammarException

Following are reasons of SQLGrammarException:

1. if the  type of id is different than the type of object passed as a parameter to session.get method .

Sunday, July 24, 2016

415 Unsupported Media Type

Hi Guys,

You might face this error while hitting a rest service which consumes request in JSON format.
Developers this might face this error when they are testing a spring based rest service.
Even if you have the dependent jars in place and spring application is successfully deployed you may still face this issue. The solution to this is include the following dependency in your pom.ml if you are using maven project.

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.8.1</version>
</dependency>

This is actually required when your spring controller is using @RequestBody.Eventhough the spring documentation site mentions this in their site you will not be prompted for a compilation error or runtime error even if you do not include the above dependency.

ec2-user@ec2 Permission denied