HFX Forum

Programming => Other Languages => Topic started by: BigAl75 on May 09, 2004, 11:51:21 PM

Title: Arrays - JAVA programming
Post by: BigAl75 on May 09, 2004, 11:51:21 PM
Anyone know how to put an object into an array?  I've been fighting with this program for 2 weeks now, and can't figure it out.

What I have to do is simulate a telephone company that monitors 100 phones.  Who calls who, how long they talk, if one phone's busy, etc.  Having problems getting the phone objects into the array.  Any help would be very appreciated.
Title: Re:Arrays - JAVA programming
Post by: wilnix on September 04, 2005, 04:46:44 AM
Here's an example of an array of objects in java:

public class ArrayOfStringsDemo {
   public static void main(String[] args) {
       String[] anArray = { "String One",
                            "String Two",
                            "String Three" };

       for (int i = 0; i < anArray.length; i++) {
           System.out.println(anArray[i].toLowerCase());
       }
   }
}


This example was pulled directly from Sun's website. The URL is: http://java.sun.com/docs/books/tutorial/java/data/arraysOfObjects.html

I hope this helps you,

Wilnix