Java Program to divide a string in 'N' equal parts.
Here, our task is to divide the string S into n equal parts. We will print an error message if the string cannot be divisible into n equal parts otherwise all the parts need to be printed as the output of the program.
To check whether the string can be divided into N equal parts, we need to divide the length of the string by n and assign the result to variable chars.
If the char comes out to be a floating point value, we can't divide the string otherwise run for loop to traverse the string and divide the string at every chars interval.
The algorithm of the program is given below.
3 equal parts of given string are aaaa bbbb cccc