-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsub_string.java
More file actions
24 lines (21 loc) · 758 Bytes
/
sub_string.java
File metadata and controls
24 lines (21 loc) · 758 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
import java.util.*;
public class sub_string{
public static void subs(String s,int start,int end){
String substring="";
for(int i=start;i<end;i++){
substring+=s.charAt(i);
}
System.out.println("substring is : "+substring);
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
System.out.print("enter a string : ");
String s=sc.nextLine();
System.out.print("enter start index : ");
int start=sc.nextInt();
System.out.print("enter the last index : ");
int end=sc.nextInt();
subs(s,start,end);
//System.out.println(s.substring(0,5)); this pri defined function in java to find the substring
}
}