Kod:
[COLOR=Green]// substring string ifadeyi parçalaya yarar.[/COLOR]
[COLOR=green]// kullanımı 1:substring(kaçıncı karakterden başlayacak)[/COLOR]
[COLOR=white]String soz =[/COLOR] [COLOR=Blue]kalktım sana geldim[/COLOR][COLOR=white];[/COLOR]
[COLOR=green] // not : boşlukta karakter olarak sayılır.[/COLOR]
[COLOR=white]soz = soz.substring(8);
System.out.println(soz);[/COLOR]
[COLOR=green] // kullanımı 2 substring(kaçıncı karakterden itibaren başlayacak,kaçıncı
// karaktere kadar gidecek)
// arasındaki stringi alır[/COLOR]
[COLOR=white]String soz2 =[/COLOR] [COLOR=blue]sonu gelmez sorumluluklar hep savunmalar, hep savunmalar[/COLOR][COLOR=white];[/COLOR]
[COLOR=white]soz2 = soz2.substring(26, 40);
System.out.println(soz2);
System.out.println();
String ad, soyad;[/COLOR]
[COLOR=white] ad =[/COLOR] [COLOR=blue]richARD[/COLOR][COLOR=white];[/COLOR]
[COLOR=white] soyad =[/COLOR] [COLOR=blue]JackSON[/COLOR][COLOR=white];[/COLOR]
[COLOR=green] // length string in karakter olarak uzunlugunu verir[/COLOR]
[COLOR=white] System.out.println(ad.length());[/COLOR]
[COLOR=green] // toLowerCase string ifadeki harfleri küçük harfe çevirir.[/COLOR]
[COLOR=white] ad = ad.toLowerCase();[/COLOR]
[COLOR=green] // toUpperCase string ifadeki harfleri büyük harfe çevirir.[/COLOR]
[COLOR=White]soyad = soyad.toUpperCase();
[/COLOR]
[COLOR=white] System.out.println(ad +[/COLOR] [COLOR=blue] [/COLOR] [COLOR=white]+ soyad);[/COLOR]
[COLOR=green]// isEmpty stringin boş olup olamadıgını kontrol eder[/COLOR]
[COLOR=white] String bos = ;[/COLOR]
[COLOR=DarkOrchid]boolean[/COLOR] [COLOR=white]bosmu = bos.isEmpty();[/COLOR]
[COLOR=white]System.out.println(bosmu);[/COLOR]
[COLOR=green] // trim Stringin baştaki ve sondaki boşluklarını siler[/COLOR]
[COLOR=white] String bosluk =[/COLOR] [COLOR=blue] Richard Jackson[/COLOR][COLOR=white];[/COLOR]
[COLOR=white] System.out.println(bosluk.trim());
System.out.println();[/COLOR]
[COLOR=green] // split stringleri dizi olarak bölmeye yarar
// kullanımı hangi karakter ile bölünceğini belirleyip
// bunu diziye aktarım ile gerçekleşir[/COLOR]
[COLOR=white]String tarih =[/COLOR] [COLOR=blue]06.06.2020[/COLOR][COLOR=white];[/COLOR]
[COLOR=white] String atarih[] = tarih.split([/COLOR][COLOR=blue]/[/COLOR][COLOR=white]);// slash[/COLOR]
[COLOR=white]System.out.println([/COLOR][COLOR=blue]gun : [/COLOR] [COLOR=white]+ atarih[0] +[/COLOR] [COLOR=blue] ay : [/COLOR] [COLOR=white]+ atarih[1][/COLOR]
[COLOR=white]+[/COLOR] [COLOR=blue] yil : [/COLOR] [COLOR=white]+ atarih[2]);[/COLOR]
[COLOR=white] System.out.println();[/COLOR]
[COLOR=green]// indexof ve lastindexof
// aranan karakter veya karakter grubunu bulunmuyorsa -1 döndürür.
String indexi = Richard Jackson;
// indexof karakter ararken soldan başlar ve
// bulunca indexini döndürür.
[COLOR=darkorchid] int[/COLOR] index = indexi.indexOf(a);
// lastindexof karakter ararken sağdan başlar.[/COLOR]
[COLOR=darkorchid] int[/COLOR] [COLOR=white]lastindex = indexi.lastIndexOf([/COLOR][COLOR=blue]a[/COLOR][COLOR=white]);[/COLOR]
[COLOR=white] System.out.println(index);
System.out.println(lastindex);
System.out.println();[/COLOR]
[COLOR=green] // stringi char olarak böle
// charat[/COLOR]
[COLOR=white] String isim = [/COLOR][COLOR=blue]Richard[/COLOR][COLOR=white];[/COLOR]
[COLOR=darkorchid] char[/COLOR] [COLOR=white]harf1 = isim.charAt(0);[/COLOR]
[COLOR=darkorchid] char[/COLOR] [COLOR=white]harf2 = isim.charAt(1);[/COLOR]
[COLOR=darkorchid]char[/COLOR] [COLOR=white]harf3 = isim.charAt(2);[/COLOR]
[COLOR=white]System.out.println(harf1 +[/COLOR] [COLOR=blue] [/COLOR] [COLOR=white]+ harf2 +[/COLOR] [COLOR=blue] [/COLOR] [COLOR=white]+ harf3);[/COLOR]
Kod:
[CENTER][CENTER][COLOR=White]sana geldim
hep savunmalar
6
richard JACKSON
true
Richard Jackson
gun : 06 ay : 06 yil : 2020
4
8
R i c
[/COLOR][/CENTER]
[/CENTER]
Faydalı olması dileğiyle Richard Jackson...
Son düzenleme: