Results 1 to 4 of 4
  1. #1
    senca is offline Member
    Join Date
    Feb 2010
    Posts
    36
    Rep Power
    0

    Default calculating with values out of another class

    hey,
    I was wonderring how you can calculate in one class using values out of antother class.

    For example:

    public class First{

    private int firstNumber;
    private int secNumber;

    ......

    }

    public class Second{

    ......

    public void makeSumofnumberintheotherclass(){
    .....
    }

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    832
    Rep Power
    6

    Default

    There is no wonder here.Learn the fundamentals and then try writing the code.
    Ramya:cool:

  3. #3
    senca is offline Member
    Join Date
    Feb 2010
    Posts
    36
    Rep Power
    0

    Default

    helpfull...

  4. #4
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    6

    Default

    you could have two public methods getFirstNumber and getSecNumber in your First class that returns the values to the Second class. if more numbers are envolved then the First class could also return an array of numbers. perhaps you could also make your calculations directly in the First class, so that you don't need to pass nothing between classes. this depends on your design.
    Last edited by j2me64; 04-08-2010 at 03:06 PM.

Similar Threads

  1. Replies: 8
    Last Post: 03-21-2009, 09:34 AM
  2. writing array values to another class
    By ronald christian in forum New To Java
    Replies: 27
    Last Post: 11-07-2008, 04:08 PM
  3. How to set values with Calendar class ?
    By mohiit in forum New To Java
    Replies: 3
    Last Post: 05-14-2008, 04:21 AM
  4. Inner Class and Calling Values
    By a45b22chp in forum New To Java
    Replies: 3
    Last Post: 04-25-2008, 08:48 PM
  5. Replies: 4
    Last Post: 04-15-2008, 01:04 PM

Posting Permissions

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