Talk:Modulinos: Difference between revisions

Line 49:
 
:That said, my current impression is that you are asking us to illustrate putting the API in a separate file from the definition of "main". If that is the case, many of the examples here (including the one I wrote) are incorrect. --[[User:Rdm|Rdm]] 13:49, 6 March 2011 (UTC)
 
== Is this something like what you want to show? ==
 
OK I'm still not clear on this, so I've kind of been avoiding it and hoping that everyone else can figure it out. I have a guess for what I think this is trying to show, though. I'll show it in Java:
<lang java5>package RC.test;
import java.util.Arrays;
 
public class MainClass{
public static void main(String[] args){
System.out.println(Arrays.toString(args));
}
}</lang>
 
<lang java5>import RC.test.MainClass;
import java.util.Arrays;
 
public class TestClass{
public static void main(String[] args){
MainClass.main({"this", "is", "a", "test");
}
}</lang>
If I would run <code>java MainClass testing 1 2 3</code> it would print:
<pre>testing
1
2
3</pre>
If I would run <code>java TestClass</code> it would print:
<pre>this
is
a
test</pre>
So the main method in MainClass is callable from another class if MainClass is imported in TestClass. I'm not sure if that means Java has a scripted main or not because that phrase means nothing to me still. What do you think? --[[User:Mwn3d|Mwn3d]] 21:20, 6 March 2011 (UTC)
Anonymous user