خلاصه مطلب
در این مطلب کاربرد متد (charAt(int index موجود در کلاس String را همراه با مثال توضیح داده ایم.
نوع محتوامقاله آموزشی
موضوعآموزش برنامه نویسی »
زمان مطالعه۱ دقیقه
آخرین ویرایش۲۱ شهریور ۱۳۹۶
| String s="www.javapro.ir"; |
.png)
| package javalike;public class CharAtExample {public static void main(String args[]) {String str = "Welcome to string handling tutorial";char ch1 = str.charAt(0);char ch2 = str.charAt(5);char ch3 = str.charAt(11);char ch4 = str.charAt(20);System.out.println("Character at 0 index is: " + ch1);System.out.println("Character at 5th index is: " + ch2);System.out.println("Character at 11th index is: " + ch3);System.out.println("Character at 20th index is: " + ch4);}} |
| Character at 0 index is: WCharacter at 5th index is: mCharacter at 11th index is: sCharacter at 20th index is: n |


