0%
Loading ...

Parvesh Sandila

Parvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master's degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​

Type Conversion in Kotlin

In this tutorial, we will learn about Type Conversion in Kotlin. In simple words type conversion means converting variable of one data type into another data type. It is important to note in Kotlin doesn't support implicit conversion of smaller data type into larger data type. Invalid Type Conversion Example: var num1 = 10 val num2: Long = num1 //Compile error, type mismatch Kotlin also supports explicit type conversion. It means a programmer can explicitly convert smaller data type into larger data type and vice-versa. There are helper functions available in Kotlin to do this. List of helper functions: toByte() toShort() toInt() toLong() toFloat() toDouble() toChar() Explicit Type Conversion Example: fun main(args : Array<String>) { var num1 = 10 val num2: Long =num1.toLong() println(num2) }   Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Type Conversion in Kotlin Read More »

Data Types in Kotlin

In this tutorial, we will learn about available Data Types in Kotlin. Data Types are used to refer to the type and size of the value in a variable. The data types in Kotlin are divided into various categories and these categories are as follow: Number Character Boolean Array String Number: This category contains all those data types which can store both normal and decimal number. There is a total of six data types in this category which are as follow: Data Type Memory Size Range Byte 8 bit -128 to 127 Short 16 bit -32768 to 32767 Int 32 bit -2,147,483,648 to 2,147,483,647 Long 64 bit -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 Float 32 bit 1.40129846432481707e-45 to 3.40282346638528860e+38 Double 64 bit 4.94065645841246544e-324 to 1.79769313486231570e+308 Example Program: un main(args: Array<String>) { val b: Byte = 1 val s: Short = 10 val i: Int = 10000 val l: Long = 100000000 val f: Float = 100.00f val d: Double = 100.00 println(“Byte Value is “+b); println(“Short Value is “+s); println(“Int Value is “+i); println(“Long Value is “+l); println(“Float Value is “+f); println(“Double Value is “+d); } Characters: In Kotlin Char data type is used to define character in variable. Char value should be defined inside single quotes ('a'). Data Type Memory Size Range Char 4 bit -128 to 127 fun main(args: Array<String>) { val gender: Char // defining variable gender = ‘M’ // Assigning value println(“Gender = “+gender) } Boolean: In Boolean data type we can store only two value which are true or false. Data Types Memory Size Values Boolean 1 bit true or false Example Program: fun main(args: Array<String>) { val flag: Boolean // defining variable flag = true // Assinging value println(“Value is “+”$flag”) } Array: In very simple language Array is a collection of homogeneous data elements. Kotlin has Array class to define an array in program. We can us arrayOf() function and Array() constructor to create an Array. Creating an array using arrayOf() function: fun main() { // declaring an array using arrayOf() val numbers = arrayOf(1, 2, 3, 4, 5) for (i in 0..numbers.size-1) { println(numbers[i]) } } Creating an array using Array Constructor: The Array constructor takes two parameters: The size of the array. A function which accepts the index of a given element and returns the initial value of that element. fun main() { val numbers = Array(5, { i -> i * 1 }) for (i in 0..numbers.size-1) { println(numbers[i]) } } String: In Kotlin String is represented as collect of characters. String is immutable in Kotlin like Java. We have two kinds of strings available in Kotlin which are raw String and escaped String. Raw String: We describe raw strings using  triple quote (""" """). We can create multi-line strings using raw strings. fun main(args: Array<String>) { var rawString :String = “”” Learn Kotlin On Owlbuddy””” println(rawString) } Escaped String: We describe Escaped strings using double quote (" "). There are various escaped characters available in Kotlin which we can use with Strings like '\n', '\t', '\b' etc. fun main(args: Array<String>) { val escapedString : String = “\nThis is escaped String!\n” println(escapedString) }   Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Data Types in Kotlin Read More »

Variables in Kotlin

In this tutorial, we will learn about Variables in Kotlin. The main motive of variables is to store data in memory while execution of a Kotlin program. The value of variables can be changed throughout the execution of the program and we change reuse variable any number of times throughout the program n Kotlin we have two keywords to declare variables. var(Mutable variable): We can change the value of the variable which declared using the var keyword. val(Immutable variable): We cannot change the value of the variable which declared using val keyword. Example of Variable using var keyword: lang = “Java”; val age = 22 Here is a really important thing to note about Kotlin variable we don't need to explicitly define the type of variable. Kotlin compiler automatically takes data type according to the value of the variable. This is known as type inference in programming. We also have another option if a programmer wants to write datatype explicitly he/she can write. Check out the example. var lang: String = “Java”; val age: Int = 22 Example of Variable using val keyword: var lang = “Java”; //We cannot change value of this variable lang = “Python”;   Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Variables in Kotlin Read More »

Hello World Program in Kotlin

In the last tutorial, we learned about how to set up the environment for Kotlin and how to start new Kotlin project in Eclipse. In this tutorial, we will learn how to write Hello World program in Kotlin. Before going further it is important to mention that we save Kotlin program files with extension .kt. If you want to save you program file with HelloWorld name you have to save it as HelloWorld.kt. Let’s check out code of our first Kotlin program. fun main (args: Array<String>){ println(“Hello World”) } To run this code you can use play button which is available in the toolbar or click on Run in the menu bar then Run As option. You will get the output of this program in the console. Hello World code Explanation: fun: In our code, you can see we started from fun. fun is a keyword in kotlin to define the function after writing fun we write function name. main(): The main function is Kotlin is same as main() in java and c. From where the execution of the program starts. In Kotlin main function take an array of string as a parameter. println(): The println() is a function which is used to print a string on the screen. We write a string in println() function in double-quotes. Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Hello World Program in Kotlin Read More »

Setup Environment for Kotlin

In this tutorial, we will learn how to setup environment for Kotlin programming. We learned in our last tutorial that Kotlin is JVM based programming language it means we have to install JDK (Java Development Kit) to run our Kotlin programs. Here I am dividing this Kotlin environment setup into four steps please follow each and every step carefully. These steps are: JDK installation IDE for Kotlin Setting up Kotlin in IDE Starting Kotlin project JDK installation: Our very first setup to setup environment for Kotlin is to download the Java development kit. We know it very well that the Java is the product of Oracle, so you can download Java Development kit from the site of Oracle. Click here to download JDK. After downloading JDK please install it in your device. It is pretty easy to install JDK while installing JDK you would get several dialogue boxes. Please follow the instructions of each dialogue box. IDE for Kotlin: After successful installation of JDK our next step will be to download the IDE (Integrated Development Environment) to write Kotlin programs. There are several IDE available in the market which we can use to write Kotlin code like Netbeans, Eclipse, and IntelliJ (by Jetbrains). You can use any IDE it’s totally up to you. But during all these tutorials I will use Eclipse. If you have already installed an IDE from these in your machine then, it’s awesome otherwise you can download it links are here (Click on the name of IDE). Netbeans Eclipse Intellij Setting up Kotlin in IDE: As I have mentioned in the previous step that during all these tutorials I will use Eclipse IDE. So if you want to setup environment for Kotlin in Eclipse the steps are as follow: Open Eclipse Click on Help in the menu bar Open Eclipse market place In the search tab, in find box write Kotlin and search. You will get plugin named “Kotlin Plugin for Eclipse (version)” install it. After successful installation of plugin restart Eclipse. Starting Kotlin project: Now we have successfully installed JDK, IDE and Kotlin plugin. It’s time to start a new project. So to do this open Eclipse IDE in your machine and go files in the menu bar select new option. Then others and select Kotlin project. In the next tutorial, we will learn about Kotlin project structure and we will also write our first program in Kotlin Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Setup Environment for Kotlin Read More »

Introduction to Java

In this tutorial, we will learn Introduction to Java. Java is an object-oriented programming language. Java language was developed by James Gosling at Sun Microsystems Inc. In starting they were thinking of naming this language Oak, But this name was already registered by another company so they named it Java. Java is a breed of coffee. So that is why the coffee mug is the logo of Java. Sun Microsystems was developed in the year 1982 by four persons. Of these four persons, One person was Vinod Khosla. He was an Indian and passed out from IIT Delhi. Java was originated at Sun Microsystem in 1991. Sun Microsystems Company developed software for Appliances. There was a problem they had to develop software for every platform even though they were working the same so that is by they invented Java language to overcome this problem. On January 27, 2010, Sun Microsystems was acquired by Oracle Corporation for the US $ 7.4 billion Java is Everywhere: It is a slogan by Java and it is true because Java resides in mobiles. Client machines, server machines, embedded devices, smartphones, cloud etc. Java Flavours: Java Versions: Version Release Date JDK Beta 1995 JDK 1.0 January 1996 JDK 1.1 February 1997 J2SE 1.2 December 1998 J2SE 1.3 May 2000 J2SE 1.4 February 2002 J2SE 5.0 September 2004 Java SE 6 December 2006 Java SE 7 July 2011 Java SE 8 (LTS) March 2014 Java SE 9 September 2017 Java SE 10 March 2018 Java SE 11 (LTS) September 2018 Java SE 12 March 2019 Java SE 13 September 2019 Java SE 14 March 2020 Java SE 15 September 2020 Java SE 16 March 2021 Java SE 17 (LTS) September 2021 Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Introduction to Java Read More »

Setup Environment for Java

In this tutorial, we will start with Java Language. To start with java, First, we have to install java in our machine and after installing java we have to set the path of java in our machine. That path will help us to run java programs in CMD. There are some commands which we use to run the program in CMD. So, to install java JDK(Java Development Kit). We have this link from where you can download Java JDK. If you want to download just click on this link. Click here to Download When you will complete this installation you will get two folders on that memory location, which you selected on the time of installation. By default its //C:Program Files/Java Java Development Kit Java Run-Time Environment Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Setup Environment for Java Read More »

First Program in Java

We will not waste our time we will directly move towards our Hello World first program in java. After writing our first program we will discuss the various things of our program why we are using them in our code what impact they are making in our code. Before starting, if you have a background in c++ or any other Object Oriented Language then that experience will help you in this series. But don’t worry Java is not that much though in starting things may be confusing for you but with the time you find everything very easy. Please keep it in your mind that, we can not write any Method or variable outside of class, It means the main function will be also part of any class. Java Code class FirstProgram { public static void main(String []args) { System.out.println("Hello World Our First Program in Java"); } } Output Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

First Program in Java Read More »

Operators in Java

In this tutorial, we will learn about Operators in Java. Operators are special symbols that we use to perform special operations like the addition of two numbers. Java provides us with a wide range of operators which help us to perform special operations. In Java, all the operators are divided into different categories All the operators are categorized according to their functionality like operators which perform mathematical operations like +, -, /, * that is in a different category and which perform relational operations are in different category like > or operators Types of Operators: – Unary Operator Arithmetic Operator Relational Operator Logical Operator Conditional Operator Difference Between operators and Operands: – Before going further let’s check out the difference between operators and operands. Operators are symbols which tell to the compiler to what kind of operation will perform and operands are values on which operation will perform. Operators and operands are together known as Expressions Operands may be in the form of Values like 10, 15 or in the form of variables such as a + b. Unary Operator: – Unary Operators are those who work with only one operand. There are two main unary operators in java which are increment(++) and decrement(–), operator. class Operators{ public static void main(String args[]) { int a=10; int b=20; int c=10; int d=20; System.out.println("Pre Inc result "+(++a)); System.out.println("Post Inc result "+(b++)); System.out.println("Pre dec result "+(–c)); System.out.println("Pre dec result "+(d–)); } } Arithmetic Operator: – Arithmetic Operators are those which help us to perform the mathematical operation there are five Arithmetic operators available in java. They are +, -, /, *, %. class Operators{ public static void main(String args[]) { int a=10; int b=20; System.out.println("Airthmetic + Opeartor: "+(a+b)); System.out.println("Airthmetic – Opeartor: "+(a-b)); System.out.println("Airthmetic / Opeartor: "+(a/b)); System.out.println("Airthmetic % Opeartor: "+(a%b)); System.out.println("Airthmetic * Opeartor: "+(a*b)); } } Relational Operator: – Relational operators help us to make compression between two operands there are six Relational operators available in java. They are , >, =, >=, ==, != . class Operators{ public static void main(String args[]) { int a=10; int b=20; System.out.println("Result of > Opeartor: "+(a>b)); System.out.println("Result of >= Opeartor: "+(a>=b)); System.out.println("Result of < Opeartor:"+(a<b)); System.out.println("Result of <= Opeartor: "+(a<=b)); System.out.println("Result of == Opeartor:"+(a==b)); System.out.println("Result of != Opeartor:"+(a!=b)); } } Logical Operator: – Instead of Operands, logical operators work on expression. There is a total of three logical operators which are && (Logical and), ||(logical or),! (logical not) Logical AND(&&): – Logical AND only returns true if have true operands on both side. other wise it returns false Operand 1 Operand 2 Result true true true true false false false true false false false false class Operators{ public static void main(String args[]) { boolean a=true; boolean b=false; System.out.println("Logical AND Result"+(a&&b)); } } Logical OR(||): – It returns true if any single or both operands are true other wise it returns false. Operand 1 Operand 2 Result true true true true false true false true true false false false class Operators{ public static void main(String args[]) { boolean a=true; boolean b=false; System.out.println("Logical OR Result"+(a||b)); } } Logical NOT(!): – It returns complement of given operands true for false and false for true: Operand Result true false false true class Operators{ public static void main(String args[]) { boolean a=true; boolean b=false; System.out.println("Logical NOT Result"+(!a)); System.out.println("Logical NOT Result"+(!b)); } } Conditional Operator: – The conditional operator is also known as utility and ternary operator is work as an if-else condition. Format to write conditional operator. condition ? if true : if false class Operator { public static void main(String[] args) { int number = 10; String result; result = (number%2 > 0) ? "Even" : "Odd"; System.out.println(number + " is " + result); } } Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Operators in Java Read More »

Keywords in Java

In this tutorial, we will learn about Keywords in Java. Java provides a wide range of keywords to us. Every keyword has some special meaning in Java. We can not use any keyword as a class name or as a variable name. All keywords have some predefined meaning which the Java compiler knows very well For example if you are using the “while” keyword then the compiler knows very well that we are going to define a loop. Like other programming languages, Java has some common keywords like if, and for. But it also has some special keywords like byte and implements. It’s important to note we can not use any keyword as the name of an identifier (as a class name, variable name or method name.) Keyword List in Java: – Parvesh SandilaParvesh Sandila is a passionate web and Mobile app developer from Jalandhar, Punjab, who has over six years of experience. Holding a Master’s degree in Computer Applications (2017), he has also mentored over 100 students in coding. In 2019, Parvesh founded Owlbuddy.com, a platform that provides free, high-quality programming tutorials in languages like Java, Python, Kotlin, PHP, and Android. His mission is to make tech education accessible to all aspiring developers.​ new.owlbuddy.com

Keywords in Java Read More »

Scroll to Top
×