For this Question: Implement the function <code>numOfWords</code>, which should take a string
and return its result as an integer which is the number of space seperated words in it (Use JS In built functions)Function will take a string as argumentFunction will return the number of space separated wordsconsole. log(numOfWords("Hi World")) // prints 2

console. log(fnumOfWords("hi")) // prints 1

console. log(numOfWords("My name is Newton")) // prints 4, I have written this Solution Code: import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int count=1;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)==' '){
				count++;
			}
		}
		System.out.println(count);
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?