OOP OSNOVE U KOTLINU
Kotlin offers solutions to common programming pitfalls, such as handling null values to avoid NullPointerException. Learn about Object-Oriented Programming basics in Kotlin, the advantages it brings, utilizing Data Classes for data storage, understanding access modifiers, working with lists, and various operations like filtering and finding elements in a collection.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
OOP OSNOVE U KOTLINU Predava i: Aleksandar Radovanovi i Mustafa Rizabegovi
KOTLIN - PREDNOSTI - Jedna od naj e ih zamki u mnogim programskim jezicima, uklju uju i i Javu, jeste da e pristupanje elementu koji za rezutat ima null vrednost produkovati NullPointerException. - Kotlin nudi opcije da se ovaj Exception spre i: 2 OOP osnove u Kotlinu
DATA KLASE - Data klase se koriste za uvanje podataka - U odnosu na "obi nu" klasu, Data klasa ima ugradjene funkcije: * get() / get(), set() * equals() / hashCode() * toString() * copy() val value var - variable 3 OOP osnove u Kotlinu
MODIFIKATORI PRISTUPA Klase, objekti, interfejsi, konstruktori i funkcije, kao i properti i njihovi seteri imaju modifikatore pristupa. Get-eri uvek imaju istu vidljivost kao i njihov properti. U Kotlinu postoje etiri modifikatora pristupa: - private - vidljiv samo unutar fajla u kome je deklarisan - protected - vidljiv unutar fajla i svim njegovim podklasama - internal - vidljiv unutar celog modula - public vidljiv unutar celog projekta Public je podrazumevani modifikator pristupa. 4 OOP osnove u Kotlinu
LISTE U KOTLINU List je generi ki uredjena kolekcija elemenata. Metode u ovom interfejsu podr avaju samo pristup listi tj. Samo itanje (immutable svojstvo). Za manipulaciju sa listama koristi se interfejs MutableList. Inicijalizacija mutable liste: Dodavanje elementa u listu: Brisanje iz liste: a) prosledjivanjem intexa (tj. pozicije u listi) ili b) vrednosti 5 OOP osnove u Kotlinu
FOR() I FOREACH() Operacije for() i forEach() nemaju povratnu vrednost. Slu e za prolazak kroz listu, kako bi se izvr io odredjeni "zadatak". Sintaksa za for() operaciju: Operacija forEach() slu i za manipulaciju nad listama: 6 OOP osnove u Kotlinu
FILTER() Operacija filter() vra a listu koja zadovoljava zadati uslov: 7 OOP osnove u Kotlinu
FIND() Find() operacija vra a jedan element niza ili null vrednost ukoliko nijedan ne zadovoljava zadati uslov. Ukoliko vi e elemenata zadovoljava uslov, find e vratiti prvi koji ga je zadovoljio 8 OOP osnove u Kotlinu
MAP() Map() operacija primenjuje modifikaciju liste po zadatom pravilu. 9 OOP osnove u Kotlinu
KOMBINOVANJE OPERACIJA 10 OOP osnove u Kotlinu
? PITANJA 11 OOP osnove u Kotlinu