Answer the question
In order to leave comments, you need to log in
Why doesn't calling the main method from another class work?
Code like this:
public class BankAccount {
int id;
String name;
double balance;
}
class BankAccountTest {
public static void main(String[] args) {
BankAccount MyAccount = new BankAccount();
BankAccount YouAccount = new BankAccount();
BankAccount HisAccount = new BankAccount();
MyAccount.id = 1;
MyAccount.name = "ZY";
MyAccount.balance = 12.35;
YouAccount.id = 2;
YouAccount.name = "BL";
YouAccount.balance = 3654.55;
HisAccount.id = 3;
HisAccount.name = "VL";
HisAccount.balance = 1662.35;
System.out.println(YouAccount.balance);
}
}
Answer the question
In order to leave comments, you need to log in
In IntellijIDEA, when moving the main method from the main class, you must change the launch configuration to designate the new class as the main class.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question