Hola! Hope you are excited to learn Kotlin and start your Android app development journey.

fun main()
{
println("Let's get started")
}
I believe that you have just begun your development journey so we will be focusing on some of the important concepts like, Object-oriented programming system.
- Object-Oriented Programming System (OOPs)
- Constructors [ Primary Constructor and Secondary Constructor ]
- Inheritance
- Abstract Classes
- Interface
- Exception Handling
But first of all, we will start by learning OOPs, Class , Methods and Objects.
Let us hear a story of Steve and Ray. Both of them decided to code in two different ways, one is “Procedural programming” and another is “Object-oriented programming”. So basically, these are two styles of writing code.
Steve has solved the program by making functions, but Ray has solved it by using class and for using the class, Ray has created some objects.
Eg. student is an object and under objects, there are a lot of properties of the object ‘student’ which are name, rollno, studentId.
Now the question arises, ‘What is a class?’
Classes are the main building blocks of any object-oriented programming language. All objects are part of a class and share the common property and behavior defined by the class in form of data members and member functions respectively.
As we can not create any direct objects in Java, Kotlin, you need to define a class and through class, you can access the properties via objects. A class shows the blueprint of the objects, you can also say the class is a prototype or class is a logical entity, we can’t use the class directly. Hence we only use class to create objects. We can create instance variables(data) and methods (fun)
Syntax:Class Student(){
// variables or data members
// member functions}
“Toh agar tumhe ghar banana ho toh, tum pehle design banaoge ,then ghar banaoge, right?” so, class is the design and ‘ghar’ is an object with its properties.
Class (name of class ) // 1st step
then ..
declare Name = variables
age = variables [ like name , age are the properties ]Object :
study() // this is behavior
{}
if () is empty, it’s fine but if you have added something inside () then add the value of it in object’s function.
For eg: className( here)
Object is a real-world entity, we can use the variables or fun that we create in the class through objects. Object is an implementation of the class.
Syntax:
Val ob= Student() // Students() is the name of the class and ob is object
Let us see some code, copy it, and run it on the compiler:
package com.kotlinc
// class : new data type
class Student() {
//variables
var name = " ray "
var age: Int = 20
// methods
fun display()
{
println("My name is ${name} and my age is ${age}")
// $ : strings interpolations
}
}
fun main() // [1st write you main function to start with kotlin]
{
println("this is my main method ")
var student1 = Student()
// [ studnets1: objects , Student() class name ] student1.name = " Steve " // [name has been overridden]
student1.age = 21
student1.display()
var student2 = Student()
student2.name = " Ray "
student2.age = 23
student2.display()
}