Results 1 to 3 of 3
  1. #1
    jwl is offline Member
    Join Date
    Jul 2012
    Rep Power

    Default Calling variables from another method

    I have created a method that generates three random points that are not collinear and are not on the same points. There are 5 loops which create five sets of three random points. Each set of random points creates a triangle. So there are 5 sets of random points which when connected make five triangles. This Only occurs in one method called GenerateRandomTriangles() {....}. My problem is after creating another method which does some computation to tell what kind of triangle it is such as "Equilateral", it needs to call the variables created in the GenerateRandomTriangles() method for each iteration of the loop so that the values change in both methods as each x and y coordinate change consecutively. I can do all this in one method but my methods are starting to get longer and longer. If someone can explain how this should be done please let me know.

    Last edited by jwl; 10-13-2012 at 09:50 PM.

  2. #2
    penguinCoder is offline Member
    Join Date
    Oct 2012
    Tempe, Arizona
    Blog Entries
    Rep Power

    Default Re: Calling variables from another method

    Couldn't you just store the points in an array and then just pass the array to the next method via the parameters?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: Calling variables from another method

    Moved from Advanced Java.

    To get better help sooner, post a SSCCE (google it) that clearly demonstrates where you have a problem.

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. calling variables in a loop?
    By SnakeDoc in forum New To Java
    Replies: 3
    Last Post: 06-14-2012, 10:54 PM
  2. Calling Variables in Multiple Methods
    By PrimalScientist in forum New To Java
    Replies: 10
    Last Post: 02-07-2012, 10:26 AM
  3. Calling Variables
    By Soulpole in forum New To Java
    Replies: 7
    Last Post: 01-28-2012, 08:26 PM
  4. Thread problem, calling method in run method
    By majk in forum Threads and Synchronization
    Replies: 4
    Last Post: 09-27-2010, 11:40 AM
  5. Replies: 29
    Last Post: 09-25-2008, 07:55 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