java - Printing Substrings -
i'm print out substrings of word, however; can't last output.
import java.util.scanner; public class printer { public static void main(string[] args) { scanner scan = new scanner(system.in); system.out.println("enter word"); string s = scan.nextline(); int i; int j; (i=1; i<s.length(); i++) { (j=0; j+i<=s.length(); j++) { string ss = s.substring(j, j+i); system.out.println(ss); } } } }
input
thunder
output
t h u n d e r th hu un nd de er thu hun und nde der thun hund unde nder thunde hunder (missing thunder)
sure put system.out.println(s); @ end, want finish loop
change outer loop condition i<=s.length
Comments
Post a Comment