using .class file in java

Discussion in 'Java' started by neha, Mar 29, 2005.

  1. neha

    neha Guest

    i have BankAPIClient.class file and now want to use it in another
    program CallBankAPIClient.java by instantiating an object of above
    class file. How to do it? guide me.....

    Regards,
    Neha Gupta
    neha, Mar 29, 2005
    #1
    1. Advertising

  2. neha

    Rhino Guest

    "neha" <> wrote in message
    news:...
    > i have BankAPIClient.class file and now want to use it in another
    > program CallBankAPIClient.java by instantiating an object of above
    > class file. How to do it? guide me.....
    >

    Add a line like this one to your CallBankAPIClient class:

    BankAPIClient myBankAPIClient = new BankAPIClient();

    Naturally, you need to pass any arguments required by the BankAPIClient
    constructor too. For example:

    BankAPIClient myBankAPIClient = new BankAPIClient(customerName,
    accountNumber);

    Then, to use the methods of the new instance, imitate this:

    myBankAPIClient.setPhoneNumber("123-3456");

    ---
    Rhino
    Rhino, Mar 29, 2005
    #2
    1. Advertising

  3. neha

    Camilla Guest

    (neha) wrote in message news:<>...
    > i have BankAPIClient.class file and now want to use it in another
    > program CallBankAPIClient.java by instantiating an object of above
    > class file. How to do it? guide me.....
    >
    > Regards,
    > Neha Gupta


    Hi! try something like this:

    import package.BankAPIClient;

    public CallBankApiClient{

    // object BankAPIClient
    BankAPIClient bap;

    public static void main(String[] args){
    //initialize object
    bap=new BankAPIClient();

    //use Object's methods
    bap.method();

    }
    }

    you can do this in the main if you're using this as a test class, and
    in all of your methods, assuming that BankAPIClass is declared as
    public in its package
    ciao, Camilla
    Camilla, Mar 29, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cyril
    Replies:
    2
    Views:
    3,858
    cyril
    Aug 25, 2004
  2. E11
    Replies:
    1
    Views:
    4,742
    Thomas Weidenfeller
    Oct 12, 2005
  3. jd
    Replies:
    3
    Views:
    352
  4. christopher diggins
    Replies:
    16
    Views:
    749
    Pete Becker
    May 4, 2005
  5. Joseph Turian
    Replies:
    5
    Views:
    587
Loading...

Share This Page