Javada Opeatorler Mod operatörü, aritmetik atama operatörü, arttırma azaltma operatörleri, ıliskisel operatorler ve kısa devre ıliskisel operatörler, kısa devre iliskisel operatorler,? operatoru Javada Operatörler; 1.Mod operatörü; package modoperatörü; String Mod [][]= new String [1][2]; Mod [][]=JOptionPane.showInputDialog("a sayısını giriniz:");//a Mod [][1]=JOptionPane.showInputDialog("mod kaça göre?");//burda da a sayısının mod(b) kaça göre olduğu yazarız. int a=(new Integer(Mod[][])).intValue();//Mod [0][0] int a ya. int b=(new Integer(Mod[][1])).intValue();//Mod [0][1] int b ye. JOptionPane.showMessageDialog(null,"Cevap;" + a % b);//a mod b ye göre sonucu / a'ya 10,moduna da 5 dersek Cevap;0 çıkacaktır. Kod çıkışı; www.dersmax.com Javada Opeatorler 1
2.Aritmetik Atama Operatörü; package iliskisel_operatorler_ve_kısa_devre_iliskisel_operat örler; //Iliskisel Operatorler ve Kısa Devre Iliskisel Operatörler String [][]= new String [1][4]; [][]=JOptionPane.showInputDialog("lütfen a sayısını giriniz:");//a [][1]=JOptionPane.showInputDialog("lütfen b sayısını giriniz:");//b [][2]=JOptionPane.showInputDialog("lütfen c sayısını giriniz:");//c [][3]=JOptionPane.showInputDialog("lütfen d sayısını giriniz:");//d int a=(new Integer([][])).intValue();//Ilisk isel_operatörler [0][0] int a ya int b=(new Integer([][1])).intValue();//Ilis kisel_operatörler [0][1] int b ye int c=(new Integer([][2])).intValue();//Ilis kisel_operatörler [0][2] int c ye int d=(new Integer([][3])).intValue();//Ilis kisel_operatörler [0][3] int d ye JOptionPane.showMessageDialog(null,"a b den küçük mü veya c sıfır degil mi " + ((a<b) c!=)); //a'ya 1,b'ye 2,c'ye 3,d'ye de 4 verdiğimizde true cevabını alırız. JOptionPane.showMessageDialog(null,"a c ye eşit ve b d ye esit degil mi " + ((a==c) & (b!=d))); //a'ya 1,b'ye 2,c'ye 3,d'ye de 4 verdiğimizde false cevabını alırız. //Kısa devre iliskisel operatorler [][]=JOptionPane.showInputDialog("lütfen e sayısını giriniz:");//e [][1]=JOptionPane.showInputDialog("lütfen f www.dersmax.com Javada Opeatorler 2
sayısını giriniz:");//f [][2]=JOptionPane.showInputDialog("lütfen g sayısını giriniz:");//g [][3]=JOptionPane.showInputDialog("lütfen h sayısını giriniz:");//h int e=(new Integer([][])).intValue();//Ilisk isel_operatörler [0][0] int e ya int f=(new Integer([][1])).intValue();//Ilis kisel_operatörler [0][1] int f ye int g=(new Integer([][2])).intValue();//Ilis kisel_operatörler [0][2] int g ye int h=(new Integer([][3])).intValue();//Ilis kisel_operatörler [0][3] int h ye //Kısa devre ilişkisel operatörlerdeki kodlar daha hızlı çalışır.yukarıdaki kodların aynısı aşağıda da var ama aşağıdakiler yukarıdaki kodlardan daha hızlı çalışmaktadır. JOptionPane.showMessageDialog(null,"e f den küçük mü veya g sıfır degil mi " + ((e<f) g!=)); //e'ye 1,f'ye 2,g'ye 3,h'a da 4 verdiğimizde true cevabını alırız. JOptionPane.showMessageDialog(null,"e g ye eşit ve f h ye esit degil mi " + ((e==g) && (f!=h))); //e'ye 1,f'ye 2,g'ye 3,h'a da 4 verdiğimizde false cevabını alırız. Kodun çıkışı; Iliskisel Operatorler ve Kısa Devre Iliskisel Operatörler; Kısa devre iliskisel operatorler; www.dersmax.com Javada Opeatorler 3
? operatoru; package soru_operatörü; //? Operatoru String soru_operatoru [][]= new String [1][4]; soru_operatoru [][]=JOptionPane.showInputDialog("lütfen a sayısını giriniz:");//a soru_operatoru [][1]=JOptionPane.showInputDialog("lütfen b sayısını giriniz:");//b soru_operatoru [][2]=JOptionPane.showInputDialog("lütfen c sayısını giriniz:");//c soru_operatoru [][3]=JOptionPane.showInputDialog("lütfen d sayısını giriniz:");//d int a=(new Integer(soru_Operatoru[][])).intValue();//soru_Operatoru [0][0] int a ya int b=(new Integer(soru_Operatoru[][1])).intValue();//soru_Operatoru [0][1] int b ye int c=(new Integer(soru_Operatoru[][2])).intValue();//soru_Operatoru [0][2] int c ye int d=(new Integer(soru_Operatoru[][3])).intValue();//soru_Operatoru [0][3] int d ye www.dersmax.com Javada Opeatorler 4
int Sonuc=((a!=b) &&!(c>d))?d:a;//a'ya 1,b'ye 2,c'ye 3,d'ye de 4 verirsek Sonuc doğru olduğundan d'ye girdiğimiz 4 sayısı Sonuc olarak çıkar. Javada Opeatorler JOptionPane.showMessageDialog(null,"c a ya esit degilse ve b d den büyüksenin degili dogruysa sonuc d degilse a Sonuc=" + Sonuc); Kodun çıkışı; Savaş Yılmaz www.dersmax.com Javada Opeatorler 5