guyzzz,,,help,,i dont know how to call a variable from other class,,could you help me,,huhuhuh,,,i really need your help...

i have a class,,
this is just a summary...

public class BankAccount{
int accountNumber[] = {1234, 2345};

public class ATM{

BankAccount bank = BankAccount();
String accountNum;
int accountNum2;

accountNum = JOptionPane.showInputDialog("Please enter your account number: ");
accountNum2 = Integer.parseInt(accountNum);

if(accountNum==bank.accountNumber[0]){
JOptionPane.showMessageDialog(null, "Card Accepted.");

}else{
JOptionPane.showMessageDialog(null,"Card is not valid.");

there is no error but when i run it,,,i dont know,,but the eclipse dont read the bank.accountNumber[0].. and prints the ("Card is not valid.")..
i dont know what to do...

help........

Recommended Answers

All 4 Replies

You are compering 2 different types String accountNum and int accountNumber[0]. This is interesting, that you run it without troubles :)
As I understand, it must be like that:
f(accountNum2==bank.accountNumber[0])

You are compering 2 different types String accountNum and int accountNumber[0]. This is interesting, that you run it without troubles :)
As I understand, it must be like that:
f(accountNum2==bank.accountNumber[0])

oh i type it wronly,,thanks for the correction,,,,

yeah in my code it was like that

if (accountNum2==bank.accountNumber[0]){
//code above..with the thread i've started.....

...help,,,

guyzzz,,,help,,i dont know how to call a variable from other class,,could you help me,,huhuhuh,,,i really need your help...

i have a class,,
this is just a summary...

public class BankAccount{
int accountNumber[] = {1234, 2345};

public class ATM{

BankAccount bank = BankAccount();
String accountNum;
int accountNum2;

accountNum = JOptionPane.showInputDialog("Please enter your account number: ");
accountNum2 = Integer.parseInt(accountNum);

if(accountNum==bank.accountNumber[0]){
JOptionPane.showMessageDialog(null, "Card Accepted.");

}else{
JOptionPane.showMessageDialog(null,"Card is not valid.");

there is no error but when i run it,,,i dont know,,but the eclipse dont read the bank.accountNumber[0].. and prints the ("Card is not valid.")..
i dont know what to do...

help........

In your BankAccount class create a getter that will return the bank account information.

public int[] getBankAccountInformation(){
    return accountNumber;
}

and then when it is returned, see if what the user inputted matches the data in the array.

In your BankAccount class create a getter that will return the bank account information.

public int[] getBankAccountInformation(){
    return accountNumber;
}

and then when it is returned, see if what the user inputted matches the data in the array.

is it really works???ok i will try this out,,,thank you for the help...thank youuuuuuuu so much guyzzz...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.