
First, specify the name of the table that you want to create after the CREATE TABLE keywords.) Code language: SQL (Structured Query Language) ( sql ) To create a new table in SQLite, you use CREATE TABLE statement using the following syntax: CREATE TABLE. Introduction to SQLite CREATE TABLE statement Using each of these in a correct place helps in debugging the code in a better way.įollow me on Twitter, Facebook or LinkedIn, will post an update when I write new posts.Summary: in this tutorial, you will learn how to create new tables using SQLite CREATE TABLE statement using various options. X!!throws a Null Pointer Exception if x is a null object and requireNotNull(x) throws IllegalArguementException if x null.Īlso, Objects.requireNotNull() is available with Java in Android, however only with the recent API versions. When I came across these two methods, I was curious to know what’s the difference between the two ways. Both throws an exception if the object is null. Kotlin provides two methods to call nullable type objects - requireNotNull() and !! operator. Kotlin’s requireNotNull() vs Not Null Assertion !! We can write x!!, and this will return a non-null value of x or throw an NPE if x is null. The not-null assertion operator ( !!) converts any value to a non-null type and throws an exception if the value is null. (I suggest to use this rarely since if you are using this operator you are actually doing the same things as we used to do in Java)

There might be cases when you know that your object cannot be null, then we use Not Null Operator !! to assert that object is not null for sure and hence avoiding the null check. In this case, if x is null, then the expression will return null as well. or Not Null Assertion !! operators have to be used to access the nullable variable. When using a nullable type, the Secure Access Operation ?. Var showButton: Button? = null // No Compile Time Error However, we can make a nullable type object, by explicitly informing Kotlin that the object can be null. Var showButton: Button = null // Compile Time Error Kotlin by default forces to initialize every object with a value and that should not be null. We just differentiate between Null and Non-Null object types in Kotlin and have to explicitly handle it as we used to do with a variable in Java.

What exactly Kotlin says is ‘ Nulls in Kotlin don’t exist until you say’, that is no variable by default is null. To my surprise, many of the Android Developers think either Koltin has removed the NPE or it handles it on its own. While exploring different possible ways to handle the NPE effectively I read various blog posts and Kotlin documentation.

We all know how Kotlin handles the “Billion Dollar Mistake” present in Java, improving the way we handle Null Pointer Exceptions (NPE).
