- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringMethod7.java
More file actions
Latest commit
31 lines (20 loc) · 762 Bytes
/
Copy pathStringMethod7.java
File metadata and controls
31 lines (20 loc) · 762 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
25
26
27
28
29
30
31
packageco.in.nextgencoder.class5;
publicclassStringMethod7 {
publicstaticvoidmain(String[] args) {
// Hello World
Stringstr = "Program";
// char str.charAt( int index)
// return character of the string from given index
charch = str.charAt(6); // m
// System.out.println(ch); // W
intstartIndex = 0; // 0
intlastIndex = str.length()-1; // 6
intmiddleIndex = lastIndex/2; // 3
charstartChar = str.charAt( startIndex); // P
charlastChar = str.charAt( lastIndex); // m
charmiddleChar = str.charAt( middleIndex); //g
System.out.println( "Starting Char ==> "+startChar); // P
System.out.println( "Ending Char ==> "+lastChar); // m
System.out.println( "Middle Char ==> "+middleChar); // g
}
}