Results 1 to 3 of 3
  1. #1
    adeeb is offline Member
    Join Date
    May 2008
    Posts
    29
    Rep Power
    0

    Default How to call methods of different classes

    Hi,
    I have written the code to add two numbers in a class named add.
    Then i have written the code to subtract two numbers in other class named sub Now i want to use this both classes in a different main class, which would give the result on running it.
    Note: All the classes are different java files
    so please someone help me out

  2. #2
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    main

    Add add = new Add();
    Sub sub = new Sub();

    add.add(numberOne, numberTwo);
    sub.sub(numberOne, numberTwo);
    My IP address is 127.0.0.1

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 1
    Last Post: 04-17-2008, 02:30 PM
  2. Replies: 0
    Last Post: 01-02-2008, 01:52 PM
  3. how to call a dll from java
    By katie in forum Advanced Java
    Replies: 3
    Last Post: 12-10-2007, 10:34 AM
  4. I need to call and run another program
    By coco in forum Advanced Java
    Replies: 1
    Last Post: 07-31-2007, 05:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •