Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: using variables from other classes in arrays :/

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default using variables from other classes in arrays :/

    So i already have this array in a TransmitterTest class:

    network = new Transmitter[networkSize] ;

    Transmitter is another class, with x y and radius variables.
    There's a few methods in it like getX, getY and getRadius that just return their values.

    The TransmitterTest class creates random values for the x and y variables, and there's a set value for radius, then they added to the network array as a Transmitter :

    network[i] = new Transmitter(x, y, radius) ;

    that all works so far.

    but i dont know how to use these values later on though in another method :/
    assumed would be something like

    network[i].Transmitter().x
    for value of x of Transmitter in i position of array, but cant get it to work.

    Any help


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: using variables from other classes in arrays :/

    Through the array, you would directly access the values of the object, in this case I suspect it would be something like:
    network[i].x

    But that's a guess without full code

Similar Threads

  1. State Variables interaction with outside classes?
    By Ace Coder in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 24th, 2010, 03:52 PM
  2. variables and efficiency
    By catkinq in forum Java Theory & Questions
    Replies: 3
    Last Post: February 7th, 2010, 06:09 AM
  3. Using variables from different methods?
    By Morevan in forum Object Oriented Programming
    Replies: 3
    Last Post: January 5th, 2010, 07:10 PM
  4. Private or public variables??
    By igniteflow in forum Java Theory & Questions
    Replies: 2
    Last Post: September 17th, 2009, 08:07 AM
  5. Java program with abstract class along with two subclasses
    By crazydeo in forum Collections and Generics
    Replies: 2
    Last Post: June 10th, 2008, 11:45 AM