简体   繁体   中英

How Do I Run Multiple instances .java Files (running one of them as an Object or Method)

I am using NetBeans IDE with Java 1.8.0

What am I doing wrong here? I want to use Output.java as - I believe - a method. Is this possible or not?

As mentioned earlier, I am using Netbeans GUI editor, so it is automatically added with the Main attribute.

(Please keep in mind that I have only really started using Java for about a week now, so I only get the concept of methods and objects.)

*Edit

public class Main {
    Output.Main. = new JTextField();
}

and

public JTextField getIn() {
    return In;
}

Where

JTextField a = getIn();
String out = Out.setText();

In and Out are JTextFields

In Java, to actually run a program, a class needs to have a method "public static void main(String[] args)" defined. When you attempt to run a Java object by compiling "javac MyClass.java" and then "java MyClass", it is the main method which actually begins running.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM