Сообщения

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

Lesson: Class and Object

 Bir paketin icinde eyni adli cemi 1 eded class duzelde bilerik. package org.example ; public class Car { public String model ; public String color ; public int year ; public static String manufacturer ; public static void staticMethod () { System . out .println( "This is static method" ) ; } public void nonStaticMethod () { System . out .println( "This is non static method" ) ; manufacturer = "Mercedes" ; } } Car . manufacturer = "General Motors" ; System . out .println( Car . manufacturer ) ; Car car = new Car() ; car .nonStaticMethod() ; System . out .println( car . manufacturer ) ; - Weird behaviour Car c = null ; c . manufacturer = "Cadillac" ; // c.model = "Island"; System . out .println( c . manufacturer ) ; // System.out.println(c.model); - Referansin qirilmasi Car one = new Car() ; one . model = "Toyota" ; one = new Car() ; o

SE_21_Lesson_5: Methods

Изображение
 1. Structure of a method 2. Method signature: Method signature consists of method name and its parameters. There can not be two methods with same signature. ----------------------------------------------------------------------------------------------------------------------------- package org.example ; public class Main { public static void main ( String [] args ) { byte b = 3 ; foo ( 3 ) ; } public static void foo ( short i ) { System . out .println( "in short" ) ; } public static void foo ( int i ) { System . out .println( "in int" ) ; } public static void foo ( long i ) { System . out .println( "in long" ) ; } } *** Advantage of using Variable arguments public static double average ( double a , double b ) { return ( a + b ) / 2 ; } public static double average ( double a , double b , double c ) { return ( a + b + c ) / 3 ; } public static double averageArray ( double [] ar

Lesson5: String. Arrays

 1. isEmpty ve isBlanc ferqi String a = "" ; System . out .println( a .isEmpty()) ; System . out .println( a .isBlank()) ; System . out .println( "-------------------" ) ; String b = " " ; System . out .println( b .isEmpty()) ; System . out .println( b .isBlank()) ; ----------------------------------------------------------------------------------------------------------------------------- Arrays int [] arr = { 1 , 2 , 3 , 4 } ;

Lesson4:Decision structures(if; if, else; if, else if, else; switch case), Repetition(while, do while, for)

1.   Scanner in = new Scanner( System . in ) ; int score = in .nextInt() ; char grade ; if ( score >= 90 ) { grade = 'A' ; } else if ( score >= 80 ) { grade = 'B' ; } else if ( score >= 70 ) { grade = 'C' ; } else if ( score >= 60 ) { grade = 'D' ; } else { grade = 'F' ; } System . out .println( grade ) ; Problem with construction of wrong logic, be cautious! Scanner in = new Scanner( System . in ) ; int score = in .nextInt() ; if ( score >= 30 ) { System . out .println( 30 ) ; } else if ( score >= 40 ) { System . out .println( 40 ) ; } else if ( score >= 50 ) { System . out .println( 50 ) ; } else if ( score >= 60 ) { System . out .println( 60 ) ; } else { System . out .println( "High" ) ; } 2. == evezine sehven = qoymayin boolean b = false ; if ( b = true ) { System . out .println( "case1" ) ; } else { System . out .println( "case2" ) ; } boole

Operators

Изображение
  1. Assignment int i = 5 ; i = i + 3 ; i += 3 ; 2. Promotion int-den daha kicik tiplerde edilen arifmetik emeliyyatlar daima int qaytarir. int i = 5 ; double d = 2.3D ; i = i + d ; // Compile time error i = ( int ) ( i + d ) ; byte b1 = 8 ; byte b2 = 5 ; byte b3 = b1 + b2 ; // Because sum is int byte b3 = ( byte ) ( b1 + b2 ) ; Ashagidaki numunelerde cast-a ehtiyac yoxdur, cunki cast avtomatik bash verir int i = 5 ; double d = 2.3D ; i += d ; 3. Pre increment, post increment, pre decrement, post decrement int i = 10 ; i ++ ; System . out .println( i ) ; i -- ; System . out .println( i ) ; ++ i ; System . out .println( i ) ; -- i ; System . out .println( i ) ; int i = 10 ; System . out .println( i ) ; System . out .println( i ++) ; System . out .println(++ i ) ; int i = 10 ; int j = i ++ ; System . out .println( i ) ; System . out .println( j ) ; int i = 10 ; int j = i ++ ; System . out .println( i ) ; System . out .println( j ) ; j = -- i ; System . out .println( i ) ; System . out .p