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: Navigating a 2d array, as in x and y coords(HELP)

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Navigating a 2d array, as in x and y coords(HELP)

    Hello all, i'm currently trying to create an alife program which simulates the life of a single organism, and its actions of eating, drinking and etc. I've already created the basic framework(pretty basic but not very smart). and in order to advance my program, I need a way to create a 2d coord system in that I can place food particles on random points on this coord map, and also have the organisms move around to different points at random, and eating only when one collides with food.

    Could someone give me a hand in the right direction?

    --- Update ---

    EDIT: Sorry to double post but the edit button was not working. I forgot to add that I WOULD provide code, but the code I currently have has nothing to do with this(Nothing is incorporated yet) and also I have NO idea where to start with this, i've tried a few things but they all failed horrible. I just need a hand in the right direction!

    --- Update ---

    Once again, not trying to double post(Thank you mod who edited my last double post) but I thought i'd add this is NOT homework. The only "attemp" I can provide is this:
    public int[][] g;
    for(int i = 0; i<g.length();i++){
    g[i][]= x;
     
    honestly i'm just going to stop there. I have no earthly idea.


  2. #2
    Member
    Join Date
    Sep 2013
    Posts
    70
    Thanks
    1
    Thanked 13 Times in 13 Posts

    Default Re: Navigating a 2d array, as in x and y coords(HELP)

    So what exactly are you attempting to accomplish? What issue are you encountering? You say you have tried a few things already but they have failed. Did the code not compile or did you get different results than you were expecting?

    In the attempt you posted you are only accessing the rows field of the array but not providing a value for the columns section.
    array[rows][columns]
    So what is the code intended to do? Be a little more specific on what the error you are getting is so we can help you more clearly.

Similar Threads

  1. Replies: 9
    Last Post: December 31st, 2011, 12:22 AM
  2. Replies: 6
    Last Post: December 6th, 2011, 07:46 AM
  3. Notepad is opening on click of submit instead navigating to other page
    By pb60705 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 10th, 2011, 06:23 AM
  4. Navigating
    By IBANGS in forum Java Theory & Questions
    Replies: 2
    Last Post: May 29th, 2010, 12:35 PM
  5. Navigating from one window to another
    By visharaddhavle83 in forum AWT / Java Swing
    Replies: 2
    Last Post: August 6th, 2009, 07:55 AM