Name to Initial Version 3

Given a name the task is to convert it to it’s initals.

Example: Consider a name “Netaji Subhas Chandra Bose”. The program should output “N. S. C. B.”.

Java
import java.util.*;
public class NameInitial
{
    public static void main(String args[])
    {
        int l=0;
        char ch=' ';
        String str,nstr="";
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a String: ");
        str=sc.nextLine();
        str=" "+str;
        l=str.length();
        for(int i=0;i<l;i++)
        {
            ch=str.charAt(i);
            if(ch==' ')
            {
                nstr=nstr+str.charAt(i+1)+". ";
            }
        }
        System.out.println("Output String: "+nstr);
    }        
}
Java