I want to return a the length of the string using 2 methods. Newbie in Java
<p>I have errors when I run program(1). But when I used program(2), writing 0 after a, it run and produced the correct output. Writing 0, is just my guess and somehow it worked. Why is that?</p>

<p><strong>Program (1):</strong></p>

<pre><code>    public static void main(String[] args) {

        System.out.println(a);

    }

    private static int a(int len) {
        String s = "What";
        len = s.length();
        return (len);
    }
}
</code></pre>

<p><strong>Program (2):</strong></p>

<pre><code> public static void main(String[] args) {

        System.out.println(a(0));

    }

    private static int a(int len) {
        String s = "What";
        len = s.length();
        return (len);
    }
}
</code></pre>
