in P8Test class why am i not able to store (scn.nextLine()).split(",") in String[] object data
<pre><code>public class TextFileExtractor{
    public static String[] fileExtractor(String[] s){

        StringBuilder sb=new StringBuilder();

        for(int i=0;i&lt;=s.length-1;i++){
            if(s[i].endsWith(".txt")){
                sb.append(s[i]);
                sb.append(',');
            }
        }
        String str=sb.toString();
        String[] sa=str.split(",");

    return sa;
}
}


//P8Test.java

import java.util.*;

class P8Test{

    public static void main(String[] args) 
    {   Scanner scn=new Scanner(System.in);
        System.out.print("Enter String Array:");
        String[] data=(scn.nextLine()).split(",");
</code></pre>

<p>/<em>Here we are storing the array which we got after converting String (which we read Dynamically) use .split() method</em>/   </p>

<pre><code>            System.out.print("all Files");
                System.out.print(Arrays.toString(data));
                    System.out.print("Text Files");

        String[] res=TextFileExtractor.fileExtractor(data);
        System.out.print(Arrays.toString(res));


    }
}
</code></pre>

<p>//in P8Test class why am i not able to store (<code>scn.nextLine()).split(",")</code> in <code>String[]</code> object data.bcoz <code>System.out.print(Arrays.toString(data));</code> is not printing anything when i give dynamic inputs like <code>abc.txt,bbc.txt,bbc.pdf.</code></p>
