Java nima Java dasturlash tili


Download 1.25 Mb.
bet9/49
Sana20.01.2023
Hajmi1.25 Mb.
#1103409
1   ...   5   6   7   8   9   10   11   12   ...   49
Bog'liq
2 5420273372074344755

public class IfExample {

  • public static void main(String[] args) {

  • int xaridorningYoshi=17;

  • if(idorningYoshi < 18){

  • System.out.print("Tamaki mahsuloti sotilmasin");

  • }

  • }

  • }



    Ekranda:
    Tamaki mahsulot sotilmasin


    int xar idorningYoshi=17; -> kiruvchi qiymat


    if(idorningYoshi < 18 ) -> tekshiruv jarayoni


    Java IF-else operatori tarifi


    Shart teksherish jarayonida shart true bo’lsa if blokdagi amal bajarladi aks holda else block dagi amal bajariladi



    1. if(condition){

    2. //code if condition is true

    3. }else{

    4. //code if condition is false

    5. }




    Misol:



    1. public class IfElseExample {

    2. public static void main(String[] args) {

    3. int number=13;

    4. if(number%2==0){

    5. System.out.println("juft son");

    6. }else{

    7. System.out.println("toq son");

    8. }

    9. }



    Ekranda:
    Toq son
     

    Java IF-else-if ketma-ketlik operatori tarifi

    O’zbekcha qilib aytganda unisi bo’lmasa bunis, bunisi bo’lmasa keyingisi degan ma’noni bildiradi.


    if-else-if ketma ketligi shartlar ko’p bo’lgan hollarda ishlatiladi.



    1. if(condition1){

    2. //code to be executed if condition1 is true

    3. }else if(condition2){

    4. //code to be executed if condition2 is true

    5. }


    6. Download 1.25 Mb.

      Do'stlaringiz bilan baham:
  • 1   ...   5   6   7   8   9   10   11   12   ...   49




    Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
    ma'muriyatiga murojaat qiling