Results 1 to 8 of 8
  1. #1
    elvis0288 is offline Member
    Join Date
    Jan 2012
    Posts
    21
    Rep Power
    0

    Default getting specific information from the array list

    hi it is me again my question now is that my professor ask me to store 4 different x and y values in an array list and i did in this way
    Java Code:
    private void createTargets()
    	{
    		double ax = 125;
    		double ay = 175;
    		double aradius = 7;
    		String input = JOptionPane.showInputDialog("Type an integer" +
    				" between 2 and 5");
    		int number = Integer.parseInt(input);
    		
    		
    		for(int i = 0; i < number; i++)
    		{
    			Target targ = new Target(ax, ay, aradius);
    			targets.add(targ);
    			Random rand = new Random();
    			ax = rand.nextInt(300) + 10;
    			
    		}
    		
    	}
    now my problem is that i need to get the individual x or y coordinates to be able to draw some circles but i do not know hot to extract the x and y coord from the array list to use it later?? help please

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: getting specific information from the array list

    Do you know how to get a Target from the ArrayList?

    Do you know how to get individual x or y coordinates from a Target?

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

  3. #3
    elvis0288 is offline Member
    Join Date
    Jan 2012
    Posts
    21
    Rep Power
    0

    Default Re: getting specific information from the array list

    Quote Originally Posted by DarrylBurke View Post
    Do you know how to get a Target from the ArrayList?

    Do you know how to get individual x or y coordinates from a Target?

    db
    I know that with an for each loop you can and a println() I can pt what I have in my array list... Individual x and Y yes you use tg or any target object name dot .getY() or getX() but I still do not know how to extraxt that to create my circles maybe it is easy but I am stuck

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: getting specific information from the array list

    I can pt what I have in my array list
    You can what?

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

  5. #5
    elvis0288 is offline Member
    Join Date
    Jan 2012
    Posts
    21
    Rep Power
    0

    Default Re: getting specific information from the array list

    pt means i can print what i have in my array list

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: getting specific information from the array list

    Quote Originally Posted by elvis0288 View Post
    pt means i can print what i have in my array list
    Not in any language I know. Please go through this.

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

  7. #7
    elvis0288 is offline Member
    Join Date
    Jan 2012
    Posts
    21
    Rep Power
    0

    Default Re: getting specific information from the array list

    I mistyped

  8. #8
    ojn
    ojn is offline Senior Member
    Join Date
    Aug 2008
    Location
    Stockholm, Sweden
    Posts
    119
    Rep Power
    0

    Default Re: getting specific information from the array list

    "pt" is not a mistype. "pritn" is a mistype. Did you also just "miss" proper punctuation and capitalizing as well?
    A lot of users on these (and other) forums won't bother with answering question if you don't appear to have put any kind of effort into it.

Similar Threads

  1. Compile Array information
    By viviosoft in forum Android
    Replies: 3
    Last Post: 09-09-2011, 11:57 PM
  2. Linked List, Array List time complexity
    By Rick99771977 in forum New To Java
    Replies: 4
    Last Post: 08-18-2011, 05:37 AM
  3. array with specific needs
    By BeginnerProgrammer in forum Java Applets
    Replies: 9
    Last Post: 06-21-2011, 03:14 AM
  4. Getting specific hash in a 2D-Array
    By benn22 in forum New To Java
    Replies: 0
    Last Post: 03-18-2011, 07:24 AM
  5. Replies: 3
    Last Post: 04-07-2008, 06:02 PM

Tags for this Thread

Posting Permissions

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