The below example demonstrates how to split a string in java.The below example defines a split() method to split the given string into an array of strings.The split() uses whitespace as delimiter to split the strings. Run It Now!
import java.io.*;
import java.util.Scanner;
public class factorial
{
public static void main(String[] agrs)
{
int prod=1,num ,i;
System.out.println("Enter a number:-");
Run It Now!