SlideShare a Scribd company logo
1 of 19
Java Dərs 4-Kontrollar və
        Dövrlər
  Murad İmanbəyli-Oracle və Java Developer
Bir artırma və azaltma Operatorları


 Dəyişənin qiymətini bir vahid azaltmaq və bir vahid
 artırmaq üçün java da xüsusi operatorlardan istifadə
 olunur.++ və - - aydındır ki ++ operatoru dəyişəni bir
 vahid artırı – bir vahid azaldır.Bunlar dəyişənin
 sağında və ya solunda gələ bilər.Hər iki halda da
 dəyişənin qiyməti bir vahid artacaqdır.Ancaq bir fərq
 varkı operator dəyişəndən əvvəl gəlidik dəyişənin
 qiyməti həmin sətirdə artır.Sonra gəldikdə isə sonrakı
 sətirdə artır
Nümünə

public class MainClass {                    public class MainClass {
 public static void main(String[] args) {    public static void main(String[] args) {
  int numA = 5;                               int numA = 5;
  int numB = 10;                              int numB = 10;
  int numC = 0;                               int numC = 0;

        numC = --numA + numB--;                     numC = ++numA + numB;
        System.out.println(numA);
        System.out.println(numC);                   System.out.println(numA);
    }                                               System.out.println(numC);
}                                               }
                                            }
Bəzi qısaldılmış operatorlar


Java da bəzi operatorları daha rahat işədək deyə
qısadılmış formaları vardır.
  x+=y ------------ x=x+y
  x-=y ------------- x=x-y
  x*=y ------------- x=x*y
  x/=y -------------- x=x/y
Şərt Operatoru(if konrtolu)


Proqramın axışını idarə etmək üçün if ifadəsi istifadə
olunur.Proqramınızda olan bir sürü kodun hansı sıra
ilə işəyəcəyini idarə edir.Bir sözlə proqramın axışını
dəyişiri.if ifadəsi boolean məntiqi tipdə bir qiymət(bu
hər hansı bir müqaysə və məntiqi operatorların
kombinasıyasıda ola bilər) alır və true olduqda if-ə aid
olan bloklar arasındakı kodlar işləyir false olduqda isə
işləmir
Nümünə


if (booleanExpression) {
   statement (s)
}


public class MainClass {
public static void main(String[] args) {
   int x = 9;
   if (x > 4) {
     // statements
   }
 }

}
Bir neçə şərt operatoru


Proqramdan verilən şərtlərə görə bir neçə şərt
operatoru istifadə etmək mümkündür.Vacib olan
şərtlərimizin bir neçəsini doğru olması ehtimalında
yanlız birini işləmısini istəyirik yoxsa doğru olanların
hamsını ona qərar verməkdir.Hər iki hal üçün də
nümünələrə baxaq
Doğru bütün şərtlərin işədiyi hal

 public class MainClass {
 public static void main(String[] args) {
   int x = 9;
   if (x > 4) {
     System.out.println(“Birinci sert”);
   }

      if(x<2){
       System.out.println(“Ikinci sert”);
       }

      if(x>7){
         System.out.println(“ucuncu sert”);
       }
  }
Doğru şərtlərin yanlız birincisin
        ödəndiyi hal
public class MainClass {
public static void main(String[] args) {
  int x = 9;
  if (x > 4) {
    System.out.println(“Birinci sert”);
  }else

        if(x<2){
         System.out.println(“Ikinci sert”);
         }else

        if(x>7){
          System.out.println(“ucuncu sert”);
         }else
    }

}
Else


Heç bir şərtin ödənmədiyi halda proqramın neçə
davam eləməsin istəyiriksə onu else bloklarının içinə
yazırıq.Else if ifadəsində həmişə ən sonuncu
gəlməlidir.Else yanlız if ifadəsinə aiddir.
public class MainClass {
public static void main(String[] args) {
   int x = 9;
   if (x > 4) {
     // statements
   } else{
    // else statements
    }
 }
Dövrlər


Dövrlər müəyyən şərtin ödəniyi halda kodlarımızı bir
dövrə sala bilərik,taki şərtimizin ödənməyi vaxta
kimi.Dövlər də konrtal ifadələri kimi boolean tipdə bir
şərt qəbul edir,əgər şərt true –dirsə dövrün sahib
olduğu kodlar işləyir və yenə geri qaytır yenə şərti
yoxlayır ,bunu dəfələrə təkrarlayır takı şərt false
qəbul edənə kimi əgər heç bir zaman şərtimiz false
olmazsa onda dövrümüz sonsuza kimi işləyəcəkdir
While Dövrü


While açar sözü ilə başlayır () arasında şərtimizi qəbul
edirik.Blok mötərizələr ilə sonlanır
     public class MainClass {

         public static void main(String[] args) {
           int i = 0;
           while (i < 3) {
             System.out.println(i);
             i++;
           }
         }

     }
Do While dövrü


Eyniylə While dövrü kimidir tək fərqi ilk əvvəl kodları
işlədir daha sonra şərti yoxlayır While da isə bu
əksinə public class MainClass {
        idi

           public static void main(String[] args) {
             int i = 0;
             do {
              System.out.println(i);
              i++;
             } while (i < 3);
           }

       }
For dövrü


For dövrü digər dövlərin daha bir yıxcam səliqləi hala
gətirilmiş formasıdır(Mənim fikim)for sözü ilə başlayır
() içində 3 ifadə qəbule dir və bir birindən ;dəyişən
elanı,şərtimiz,dəyişənin artma aralığı

For(deyisen ;sert;arma araligi){

}
Nümünə


public class MainClass {

    public static void main(String[] args) {
      for (int i = 0; i < 5; i++) {
        System.out.println(i + " ");
      }
    }
}
Continue


Bir sonrakı dövrə keçməyi sağlıyır
      public class MainClass {

          public static void main(String[] args) {
            for (int i = 0; i < 10; i++) {
              if (i == 5) {
                continue;
              }
              System.out.println(i);
            }
          }

      }
Break


Dövrdən çıxmağı sağlıyır   public class MainClass {

                               public static void main(String[] args) {
                                 int i = 0;
                                 while (true) {
                                   System.out.println(i);
                                   i++;
                                   if (i > 3) {
                                       break;
                                   }
                                 }
                               }

                           }
Qeyd


Java da Kodlar sətir bə-sətir işləyir
Suallar


Murad İmanbəyli-Oracle və Java Developer
http://muradimanbayli.com

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Java ders4

  • 1. Java Dərs 4-Kontrollar və Dövrlər Murad İmanbəyli-Oracle və Java Developer
  • 2. Bir artırma və azaltma Operatorları Dəyişənin qiymətini bir vahid azaltmaq və bir vahid artırmaq üçün java da xüsusi operatorlardan istifadə olunur.++ və - - aydındır ki ++ operatoru dəyişəni bir vahid artırı – bir vahid azaldır.Bunlar dəyişənin sağında və ya solunda gələ bilər.Hər iki halda da dəyişənin qiyməti bir vahid artacaqdır.Ancaq bir fərq varkı operator dəyişəndən əvvəl gəlidik dəyişənin qiyməti həmin sətirdə artır.Sonra gəldikdə isə sonrakı sətirdə artır
  • 3. Nümünə public class MainClass { public class MainClass { public static void main(String[] args) { public static void main(String[] args) { int numA = 5; int numA = 5; int numB = 10; int numB = 10; int numC = 0; int numC = 0; numC = --numA + numB--; numC = ++numA + numB; System.out.println(numA); System.out.println(numC); System.out.println(numA); } System.out.println(numC); } } }
  • 4. Bəzi qısaldılmış operatorlar Java da bəzi operatorları daha rahat işədək deyə qısadılmış formaları vardır. x+=y ------------ x=x+y x-=y ------------- x=x-y x*=y ------------- x=x*y x/=y -------------- x=x/y
  • 5. Şərt Operatoru(if konrtolu) Proqramın axışını idarə etmək üçün if ifadəsi istifadə olunur.Proqramınızda olan bir sürü kodun hansı sıra ilə işəyəcəyini idarə edir.Bir sözlə proqramın axışını dəyişiri.if ifadəsi boolean məntiqi tipdə bir qiymət(bu hər hansı bir müqaysə və məntiqi operatorların kombinasıyasıda ola bilər) alır və true olduqda if-ə aid olan bloklar arasındakı kodlar işləyir false olduqda isə işləmir
  • 6. Nümünə if (booleanExpression) { statement (s) } public class MainClass { public static void main(String[] args) { int x = 9; if (x > 4) { // statements } } }
  • 7. Bir neçə şərt operatoru Proqramdan verilən şərtlərə görə bir neçə şərt operatoru istifadə etmək mümkündür.Vacib olan şərtlərimizin bir neçəsini doğru olması ehtimalında yanlız birini işləmısini istəyirik yoxsa doğru olanların hamsını ona qərar verməkdir.Hər iki hal üçün də nümünələrə baxaq
  • 8. Doğru bütün şərtlərin işədiyi hal public class MainClass { public static void main(String[] args) { int x = 9; if (x > 4) { System.out.println(“Birinci sert”); } if(x<2){ System.out.println(“Ikinci sert”); } if(x>7){ System.out.println(“ucuncu sert”); } }
  • 9. Doğru şərtlərin yanlız birincisin ödəndiyi hal public class MainClass { public static void main(String[] args) { int x = 9; if (x > 4) { System.out.println(“Birinci sert”); }else if(x<2){ System.out.println(“Ikinci sert”); }else if(x>7){ System.out.println(“ucuncu sert”); }else } }
  • 10. Else Heç bir şərtin ödənmədiyi halda proqramın neçə davam eləməsin istəyiriksə onu else bloklarının içinə yazırıq.Else if ifadəsində həmişə ən sonuncu gəlməlidir.Else yanlız if ifadəsinə aiddir. public class MainClass { public static void main(String[] args) { int x = 9; if (x > 4) { // statements } else{ // else statements } }
  • 11. Dövrlər Dövrlər müəyyən şərtin ödəniyi halda kodlarımızı bir dövrə sala bilərik,taki şərtimizin ödənməyi vaxta kimi.Dövlər də konrtal ifadələri kimi boolean tipdə bir şərt qəbul edir,əgər şərt true –dirsə dövrün sahib olduğu kodlar işləyir və yenə geri qaytır yenə şərti yoxlayır ,bunu dəfələrə təkrarlayır takı şərt false qəbul edənə kimi əgər heç bir zaman şərtimiz false olmazsa onda dövrümüz sonsuza kimi işləyəcəkdir
  • 12. While Dövrü While açar sözü ilə başlayır () arasında şərtimizi qəbul edirik.Blok mötərizələr ilə sonlanır public class MainClass { public static void main(String[] args) { int i = 0; while (i < 3) { System.out.println(i); i++; } } }
  • 13. Do While dövrü Eyniylə While dövrü kimidir tək fərqi ilk əvvəl kodları işlədir daha sonra şərti yoxlayır While da isə bu əksinə public class MainClass { idi public static void main(String[] args) { int i = 0; do { System.out.println(i); i++; } while (i < 3); } }
  • 14. For dövrü For dövrü digər dövlərin daha bir yıxcam səliqləi hala gətirilmiş formasıdır(Mənim fikim)for sözü ilə başlayır () içində 3 ifadə qəbule dir və bir birindən ;dəyişən elanı,şərtimiz,dəyişənin artma aralığı For(deyisen ;sert;arma araligi){ }
  • 15. Nümünə public class MainClass { public static void main(String[] args) { for (int i = 0; i < 5; i++) { System.out.println(i + " "); } } }
  • 16. Continue Bir sonrakı dövrə keçməyi sağlıyır public class MainClass { public static void main(String[] args) { for (int i = 0; i < 10; i++) { if (i == 5) { continue; } System.out.println(i); } } }
  • 17. Break Dövrdən çıxmağı sağlıyır public class MainClass { public static void main(String[] args) { int i = 0; while (true) { System.out.println(i); i++; if (i > 3) { break; } } } }
  • 18. Qeyd Java da Kodlar sətir bə-sətir işləyir
  • 19. Suallar Murad İmanbəyli-Oracle və Java Developer http://muradimanbayli.com