| | |
How to call a variable from other class
![]() |
•
•
Join Date: Oct 2008
Posts: 37
Reputation:
Solved Threads: 0
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........
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........
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])

As I understand, it must be like that:
f(accountNum2==bank.accountNumber[0])
So what if you can see the darkest side of me?
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
No one would ever change this animal I have become
Help me believe it's not the real me
Somebody help me tame this animal
•
•
Join Date: Oct 2008
Posts: 37
Reputation:
Solved Threads: 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,,,
Last edited by l_03; Nov 16th, 2008 at 11:05 pm.
•
•
•
•
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........
java Syntax (Toggle Plain Text)
public int[] getBankAccountInformation(){ return accountNumber; }
and then when it is returned, see if what the user inputted matches the data in the array.
•
•
Join Date: Oct 2008
Posts: 37
Reputation:
Solved Threads: 0
•
•
•
•
In your BankAccount class create a getter that will return the bank account information.
java Syntax (Toggle Plain Text)
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...
![]() |
Similar Threads
- Class and Sub Class (Java)
- class constructor help (C#)
- Instantiating an Object of a Class Confusion (Java)
- simple call (Java)
- Class question (PHP)
- illegal call of non-static member function (C++)
- Bank account class (C++)
- accessing private data members (C++)
- Help with casting (Java)
Other Threads in the Java Forum
- Previous Thread: grid in jsp
- Next Thread: How to Know Whether an Object with Specified Name Exists For a Class are not
| Thread Tools | Search this Thread |
6 @param actuate android api applet application arc array arrays automation balls binary bluetooth bold business byte c++ chat class client code codesnippet collections compare component coordinates database defaultmethod detection doctype dragging ebook eclipse educational error file fractal froglogic game givemetehcodez graphics gui guitesting helpwithhomework hql html ide ideas image ingres input integer internet intersect invokingapacheantprogrammatically j2me java javaexcel javaprojects jni jpanel jtextarea julia linux list map method methods mobile mysql netbeans newbie nextline parameter php pong problem program programming project recursion recursive scanner sell server set sms sort sql string sun swing swt terminal threads tree web websites windows





