How to call a function with some return type from function of Main class in Java? : <p>I am writing a java program to search a character/word in multiple files, so I am accepting the list of Keywords to search in command line argument i.e. String[] args, and I want to store there values in a ArrayList object.</p>

<p>I have main class name : <strong>CharSearchTool</strong>, Another class in same package : <strong>ArrayListFromParameters</strong></p>

<pre><code>package com.charsearchtool;

public class CharSearchTool {
    public static void main(String[] args) {
        ArrayListFromParameters arrayList = new ArrayListFromParameters(args);
        System.out.println(arrayList.list);
    }
}




package com.charsearchtool;

import java.util.ArrayList;

public class ArrayListFromParameters {
    ArrayList&lt;String&gt; list = new ArrayList&lt;String&gt;();

    public ArrayList&lt;String&gt; ArrayListFromParameters(String[] argument) {
        for (int i = 0; i &lt; argument.length; i++) {
            list.add(argument[i]);
        }
        return (list);
    }
}
</code></pre>

<p>I am getting error on below line :</p>

<pre><code>ArrayListFromParameters arrayList = new ArrayListFromParameters(args);
</code></pre>

<p><strong>Error : The constructor ArrayListParameters(String[]) is undefined.</strong></p>
