
input any word ie risk,resul is--
r ri ris risk

Hi Friend,
Try the following code:
import java.util.*;
class StringExample3
{
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter word: ");
String st=input.next();
for(int i=0;i<=st.length();i++){
int j=i+1;
System.out.println(st.substring(0,i));
}
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.