Сообщения

Сообщения за март, 2022

Operators

 Operators in Java can be classified into  6 types: 1. Arithmetic operators   2. Assignment operators   3. Relational operators   4. Logical operators 5. Unary operators    6. Bitwise operators 1. Arithmetic operators: are used to perform operations on variables and data. +: addition -: subtraction *: multiplication /: division %: remainder, modulus, mod 2. Assignment operators: are used in Java to assign values to variables.  =;   +=;   -=;   *=;   /=;   %= 3. Relational operators:  are used to check the relationship between two operands. It returns either true or false ==: is equal to !=: not equal to >: greater than <: less than >=: greater than equal to <=: less than equal to 4. Logical operators: are used to check whether an expression is true or false. They are used in decision making.  && (Logical AND)  || (Logical OR)  ! (Logical NOT) 5. Unary operators: are used with only one operand. +: unary plus. not necessary to use since numbers are positive without us

Numeric Promotion, Numeric Type Conversion(Widening, Narrowing)

Изображение
 1. If two values have different data types, Java will automatically promote one of the values to the larger of the two data types.  2. If one of the values is integral and the other is floating-point, Java will automatically promote the integral value of the floating-point value's data type.  3. Smaller data types, namely byte, short and char, are first promoted to int any time they're used with a Java binary arithmetic operator, even if neither of the operand is int. 4. After all promotion has occurred and the operand have the same data type, the resulting value will have the same data type as its promoted operand.  int a = 4 ; System . out .println(- a ) ; int b = - 3 ; System . out .println(+ b ) ; Outcome: -4 and -3; Cunki musbetle menfi neticede menfi verir. Order of operator precedence Post-unary operators : expression++, expression-- Pre-unary operators: ++expression, --expression Other unary operators: +, -, ! Multiplication/Division/Modulus: *, /, % Addition/Subtracti

Heap and Stack

Изображение
  Heap - JVM terefinden obyekt yaratmaq ucun iwlenilen yaddaw yeridir. Buna dynamic memory area da deyilir. Normalda stack - dan daha boyukdur.  Stack - LIFO(last in first out) prinsipi ile iwleyir. Stack proqramda o anda caliwan, aktiv olan metodlar ucun ayrilan yaddawdir. main- den davam ederek, cagrilan her yeni metod ucun stackda uste yeni bir pencere acilir. Metod iwini bitirende, onu cagiran metoda qayidarken stack-daki pencereleride silir. Stack-daki yaddaw pencereleri onun ucun acilan metodun parametrlerini local deyiwenlerini saxlayir. One gore de local variable -larina stack variable deyilir.  *** Bir variable eger obyektin bir hissesidirse yeni object variable - dirsa(field) bu zaman heap yaddawdadir. Yox eger local variable-dirsa stack yaddawdadir.  Mes:  Car car = new Car(); car.make = "Mercedes"; car.model = "C200"; int speed = car.speed; Burada: speed, car - stackda yerlewir, Car obyekti ise heap yaddawdadir, hemcinin ona mensub olan make, model de he

N+1 problem. Fetch types. @Transactional annotation

 @OneToMany ve @ManyToMany - de eger fetch type EAGER -dirse o zaman N + 1 problemi ortaya cixir. N + 1 o demkdirki Many terefde ne qeder obyekt varsa hamisini cekib getirir ve her birisi ucun ayrica query icra olunur. Bunun qarshisini almaq ucun fetch type LAZY qoyulur ve @Transactional annotation istifade olunur.  1-ci situasiyada butun query-ler iwleyir sonra cap olunur. 2-ci situasiyada ise lazim olduqca query-ler iwleyir. Solutions for N + 1 problem. 1. Join Fetch public interface CourseRepository extends JpaRepository < Course , Long > { // JPQL java persistence query language @Query (value = " select c from Course c join fetch c.students s " ) List < Course > getAllCourses () ; } Bu zaman cemi bir defe Hibernate query generate edecek. 2. NamedEntityGraph EntityGraphType iki cur olur: FETCH ve LOAD FETCH - qeyd olunubsa o zaman value = "something" qeyd olunanlari EAGER weklinde getirir, qalanlarini ise LAZY weklinde getirir. Hetta hemi

Variables

 Javada iki cur varialbe var: primitive type and reference(complex type, reference type) Primitive 1. boolean - 1 bit. true or false. By default false. 2. byte - 8 bit integral value. 0 3. short - 16 bit integral value. 0 4. int - 32 bit integral value. 0 5. long - 64 bit integral value. 0 6. float - 32 bit floating-point value. 0.0f 7. double - 64 bit floating-point value. 0.0f 8. char - 16 bit Unicode value. '\u0000' variable(identifier)  - lar istenilen herf, $, _  bawlaya biler. variable adinda . istifade oluna bimez.   Mes: float f = 4; float n = 4,3F; long k = 3L; double s = 3; double d = 3.6; Ikilik say sistemi: 0b veya 0B  ile bawlayir.  Sekkizlik say sistemi: 0 ile bawlayir. Onaltiliq say sistemi: 0x ile bawlayir.  Declaration: boolean b; Initialization: b = true; Definition: int i = 6; Definition = declaration + initialization Unicode elementleri '\uxxxx' weklinde ifade edilir.  'x' 16-liq say sistemindeki (hexadecimal) reqemlerdir. Yeni bir Unicode ko

Class, Object and Constructor

Изображение
1. Class.   Class - is a user defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type.  2.  Block -  is a set of code enclosed within curly braces {} within any class , method, or constructor.  There are two types of block in Java :  static Block, instance (non-static) Block. 3. Constructor . Constructor - is a similar to method that invoked when an object of the class is created. Konstruktorun return tipi olmur. Eger biz ozumuz konstruktor yaradiriqsa o zaman Java ozu default konstruktor yaratmir. Konstuktor hemiwe instance block -dan sonra iwe duwur.  Exercise 1: public class Main { static { System . out .println( "This is static block" ) ; Main main = new Main() ; } { System . out .println( "This is instance block" ) ; } public Main () { System . out .println( "This is a constructor" ) ; } public st

Docker

 1. docker image pull virtualpairprogrammers/fleetman-webapp . Bu komanda docker hub-dan image docker-e yukleyir.  2. docker container run {image name} : docker container run virtualpairprogrammers/fleetman-webapp. Bu komanda image-i run etmek ucundur. 3. docker container run -p 8080:8080 virtualpairpogrammers/fleetman-webapp . -p komandasi xarici port vermak ucun istifade olunur, yeni xarici portu dockerin icindeki porta birlewdirir. 4.  docker container run -p 8080:8080 -d virtualpairpogrammers/fleetman-webapp : -d burada container-i detacht modda caliwdirir, yeni arxa modda ozu caliwacaq. -d komandasini run komandasindan sonrada vere bilerik. 5. docker container ls veya docker container ps veya docker ps : bu komanda butun run olan yeni ayaqda olan container-leri gosterir 6. docker ps -a veya docker container ls -a : bu komanda iwleyen ve iwlemeyen butun container-leri gosterir. 7. docker container stop {container id} : docker container stop 9d6263cc69a0 . Bu komanda run oland co

Primitive knowledge about Java

 1.  MyNameIsParvin - pascal naming convention myNameIsParvin - camel naming convention 2. System.out.println(1 + 2 + 3 + "Hello"); output : 6Hello System.out.println("Hello" + 1 + 2 + 3); output: Hello123 3. Comments: // single line comment /* multi line comment */ /** java doc comment */ 4. Javada fayl ve klas anlayiwi: mes: Main.java fayl sayilir, ve bu faylin icinde faylin adina uygun public klas olmalidir, yeni hemid adda public klas olmalidir. Main.java (fayl) --> public class Main. Bir faylin icinde bir veya bir nece klas ola biler, lakin mutleq wekilde hemin faylin adina uygun public klas olmalidir. Ve bir faylin icinde yalniz ve yalniz bir public klas ola biler. 5. Package ve import anlayiwi: Ilk once by default istenilen yaradilan klasin icine java.lang package-inin icindeki butun klaslar import olunur.  6. Wild card import: import java.util.*; - bu o demekdirki java package-nin icindeki util packagenin icindeki butun klaslari import ele.  Mes: biz anim

Java nedir?

  Compilation — source kodun mashinin basha dusheceyi dile cevrilmesidir. It is the process the computer takes to convert a high-level programming language into a machine language that the computer can understand. Source code — — ->compiling — —->Binary code (0 ; 1) Compiler — programi tam cevirir sonra icra edir. Compiler xetalari cevirenden sonra deyir. Interpreter — programi setir setir oxuyur ve icra edir. Interpreter xetalari ilk sehv tapildiqda deyirl. Compiled languages : C, C++, Go, Fortran, Pascal. Language → (Compiling) → Machine code → Ready to Run! Interpreted languages: Python, PHP, Ruby, JavaScript. Language → Ready to Run! → (Interpreting) → Virtual Machine → Machine code. Java hem compiler hem de interpreter dildir. MyProgram.java → (Compiler) → MyProgram.class → (JVM) → MyProgram(01000110101010) Java Compile-time platfomadan asili deyil, Bytecode platformadan asili deyil lakin JVM-den asilidir, Run-time da ise platformadan asilidir. JDK((JRE(JVM))). JDK — Java De