-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.java
More file actions
36 lines (25 loc) · 1.34 KB
/
main.java
File metadata and controls
36 lines (25 loc) · 1.34 KB
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
32
33
34
35
36
public class main {
public static void main(String[] args) {
String str="hello world!";
System.out.println(str.length());// this is count the character of the string
System.out.println(str.charAt(7));
// this method is return the character at the inde position
System.out.println(str.substring(7));
// this method return the substring from the ith index caracter to end
System.out.println(str.substring(2,6));
//Returns the substring from i to j-1 index.
System.out.println(str.concat("saniya"));
// Concatenates specified string to the end of this string
System.out.println(str.indexOf('o'));
/*Finds the position of the first occurrence of the given
substring within the main string. If the specified string s is
not found in the input string, the method returns -1 by default. */
System.out.println(str.indexOf('l',3));
//Returns the index within the string of the first occurrence
// of the specified string, starting at the specified index.
System.out.println(str.lastIndexOf('l', 3));
/*Returns the index within the string of the last occurrence of the specified string.
If the specified string s is not found in the input string,
the method returns -1 by default. */
}
}