Posted On: Dec 24, 2020
The JAVA program to find all substrings of a string:
import java.util.Scanner; class SubstringsOfAString { public static void main(String args[]) { String string, sub; int i, c, length; Scanner in = new Scanner(System.in); System.out.println("Enter a string to print it's all substrings"); string = in.nextLine(); length = string.length(); System.out.println("Substrings of \""+string+"\" are :-"); for( c = 0 ; c < length ; c++ ) { for( i = 1 ; i <= length - c ; i++ ) { sub = string.substring(c, c+i); System.out.println(sub); } } } }
Never Miss an Articles from us.
The STP also stands for Spanning Tree Protocol constructs a loop-free logical topography for Ethernet networks. It is a ..
A prime number is a whole number greater than 1, which is only divisible by 1 and itself. // function check whether a number // is prime or not bool isPrime(int n) { // Corner case if (n...
A regular expression to validate phone number in XXX-XXX-XXXX format is follows: /^(?:\(\d{3}\)|\d{3}-)\d{3}-\d{4}$/...