-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString_3.java
More file actions
24 lines (17 loc) · 859 Bytes
/
String_3.java
File metadata and controls
24 lines (17 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package basicjava;
public class String_3 {
public static void main(String[] args) {
String country = " Bangladesh is my country ";
System.out.println(country);
String s3 = country.trim();
System.out.println("After removing the spaces from the first and last in the string: "+s3);
char ch = country.charAt(0);
System.out.println("Character at 0 index: "+ch);
int value = country.codePointAt(0);
System.out.println("The ascii value of the character at index 0: "+value);
int pos = country.indexOf('n');
System.out.println("The first index of 'n' in the string: "+pos);
pos = country.lastIndexOf('n');
System.out.println("The last index of character 'n' is: "+pos);
}
}