Сообщения

Сообщения за декабрь, 2022

Big O Notation

1. Big O : It is a complexity that is going to be less or equal to the worst case. 2. Big Omega : It is a complexity that is going to be at least more than the best case. 3. Big Theta : It is a complexity that is within bounds of the worst and the best cases. Runtime complexities: 1. O(1) : Constant. Accessing a specific element in array int [] arr = { 1 , 5 , 3 , 9 , 4 } ; int el = arr [ 3 ] ; 2. O(N) : Linear. Loop through array elements int [] arr = { 1 , 5 , 3 , 9 , 4 } ; for ( int i = 0 ; i < arr . length ; i ++) { System . out .println( arr [ i ]) ; } 3. O(Log N) : Logarithmic. Find an element in stored array  int [] arr = { 1 , 5 , 3 , 9 , 4 , 2 , 8 , 6 } ; for ( int i = 0 ; i < arr . length ; i += 3 ) { System . out .println( arr [ i ]) ; } Another example is Binary search. 4. O(N^2) : Quadratic. Looking at every index in the array twice. int [] arr = { 1 , 5 , 3 , 9 , 4 , 2 , 8 , 6 } ; for ( int i = 0 ; i < arr . length ; i ++) { for ( int j = 0 ; j < a

Oracle database with docker

Изображение
https://geraldonit.com/2021/08/15/oracle-xe-docker-images/   1. docker command: docker run --name oracle-xe-slim -p 1521:1521 -e ORACLE_RANDOM_PASSWORD=true gvenzl/oracle-xe:18-slim 2. data gripden qowulmaq ucun: bele bir password generate olunacaq. password yerine docker generate etdiyi password yaziriq. 3. user yaradilmalidir: create user parvin identified by parvin temporary tablespace TEMP default tablespace USERS quota unlimited on USERS ; 4. hemin user-e grant verilmelidir: grant connect , resource to parvin ; 5.  esas bazanin uzerine sag klik edib duplicate duymesine basib, sonra credentiallari daxil edib qowuluruq Docker compose file: *** lakin diqqet etmek lazimdir ki, bu compose faylini hansisa foldere atmaq lazimdir. Sonra ise git bash ile docker compose up etmek lazimdir. version : '3.3' services : oracle : image : gvenzl/oracle-xe:18-slim volumes : - ./oracle-volume:/opt/oracle/oradata ports : - 1991:1521 environment : ORACLE_RAN

EntityManager persists and merge

  Either way will add an entity to a PersistenceContext, the difference is in what you do with the entity afterwards. Persist takes an entity instance, adds it to the context and makes that instance managed (i.e. future updates to the entity will be tracked). Merge returns the managed instance that the state was merged with. It does return something that exists in PersistenceContext or creates a new instance of your entity. In any case, it will copy the state from the supplied entity, and return a managed copy. The instance you pass in will not be managed (any changes you make will not be part of the transaction - unless you call merge again). Though you can use the returned instance (managed one). MyEntity e = new MyEntity (); // scenario 1 // tran starts em.persist(e); e.setSomeField(someValue); // tran ends, and the row for someField is updated in the database // scenario 2 // tran starts e = new MyEntity (); em.merge(e); e.setSomeField(anotherValue); // tran ends but

SE_19_Lesson_4: Delimiters

Delimiter - is white space that separates input data. Scanner skips delimiter. *** Scanner.nextLine - it reads the current line. Elave olaraq Scanner.nextLine iwletmeliyikki problem yawamayaq. Scanner sc = new Scanner(System. in ) ; System. out .println( "Please enter a number:" ) ; int num = sc.nextInt() ; System. out .println(num) ; sc.nextLine() ; System. out .println( "Please enter a sentence:" ) ; String sentence = sc.nextLine() ; System. out .println(sentence) ; Eger Scannerden reqemsal melumat isteyirikse ve ondan sonra String isteyirikse, o zaman bow sc.nextLine(); yazmaliyiq 

Lesson_4: Control flow

1. if(), if() else(), if() else if() else() a) Simple if else case Scanner in = new Scanner( System . in ) ; int a = in .nextInt() ; if ( a > 0 ) { System . out .println( "Positive" ) ; } else if ( a == 0 ) { System . out .println( "Neutral" ) ; } else { System . out .println( "Negative" ) ; } System . out .println( "Continue..." ) ; b) Wrong if else case Scanner in = new Scanner( System . in ) ; int grade = in .nextInt() ; if ( grade > 90 && grade <= 100 ) { System . out .println( "A" ) ; } else if ( grade > 80 ) { System . out .println( "B" ) ; } else { System . out .println( "Fail" ) ; } System . out .println( "Continue..." ) ; When we input for example 150 code crashes. Random random = new Random() ; int grade = random.nextInt( 100 ) ; if (grade > 90 ) { System. out .println(grade + " A" ) ; } else if (grade > 80 ) { System. out .printl

Lesson_2: Operations in Java

1. Capda toplama emeliyyatinin ferqi: package org.example.test ; public class Test { public static void main (String[] args) throws Exception { int one = 1 ; int two = 2 ; System. out .println( "result = " + one + two) ; System. out .println(one + two + " result" ) ; } }   char a = 'a' ; char b = 'b' ; System. out .println(a + b) ; System. out .println( 'a' + 'b' ) ; System. out .println( "" + a + b) ; System. out .println( "" + 'a' + 'b' ) ; 2. float ve double-da bash veren riyazi emaliyyat xeyalari: package org.example.test ; public class Test { public static void main (String[] args) throws Exception { float f = 0.6F ; System. out .println(f + 0.1 ) ; } } Operators in Java Operators in Java can be classified into 5 types: Arithmetic Operators Assignment Operators Relational Operators Logical Operators Unary Operators Bitwise Operator