× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Getting Certain Method Into Main Method in Java

James Jensen
Feb 10, 2015
<p>Your <code>main</code> method is <code>static</code>, but your <code>results</code> method is not. Either make <code>results</code> be <code>static</code>, or declare a <code>new</code> instance of your class to use inside of <code>main</code>.</p> <pre><code>public class MyClass { public static void main(String[] args) { results(1); } public static void results (int num) { } } </code></pre> <p>or </p> <pre><code>public class MyClass { public static void main(String[] args) { new MyClass().results(1); } public void results (int num) { } } </code></pre> <p>This tip was originally posted on <a href="http://stackoverflow.com/questions/24790790/Getting%20Certain%20Method%20Into%20Main%20Method%20in%20Java/24790839">Stack Overflow</a>.</p>
comments powered by Disqus