Results 1 to 4 of 4
  1. #1
    iPetey is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Question [SOLVED] Array Programming Construct?

    I'm working on an assignment for my java class and this is one of my last steps:

    "Redo part 2 with an array programming construct instead of an ArrayList."

    i hope i don't sound like a complete newb but is an array programming construct ?:
    Java Code:
    String[] Movies = { "Batman", "Superman", "Spiderman", "Ironman" };
    Part2 is a for loop:(sorry if its not formatted correctly idk how to)
    Java Code:
        private void intialiseFavMovies()
        {
            Movies.add("Batman");
            Movies.add("Scarface");
            Movies.add("Half-Baked");
            Movies.add("A Bronx Tale");
            Movies.add("Paid In Full");
            Movies.add("Home Alone 2");
            Movies.add("Goodfellas");
            Movies.add("Casino");
            Movies.add("Superbad");
            Movies.add("Teenage Mutant Ninja Turtles 2");
        }
    
        public void doForLoop()
        {
          Movies = new ArrayList<String>();
          intialiseFavMovies();
          for (int i = 0; i < Movies.size(); i++) {
          System.out.println(Movies.get(i));
         }
    i hope i explained my problem clearly.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    A bit of confuse.

    Is that Movies is an ArrayList, and were you define? I cannot see that, only the initialization.

  3. #3
    iPetey is offline Member
    Join Date
    Apr 2009
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    A bit of confuse.

    Is that Movies is an ArrayList, and were you define? I cannot see that, only the initialization.
    Java Code:
    public class Test
    {
        
        private ArrayList<String> Movies;
    idk what you mean. basically my program has a bunch of different methods doing the same thing (listing the movies) but in a different way(different types of loops)

    the 6th part is to redo the second part using an array programming construct instead of an arraylist.Select either the for loop or while loop to print out contents of the array.

    i dont really understand what array programming construct means
    Last edited by iPetey; 04-09-2009 at 02:48 AM.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Java Programming, Array Help
    By Just Incredible in forum New To Java
    Replies: 2
    Last Post: 01-24-2009, 03:18 PM
  2. How to construct my finished program?
    By matpj in forum New To Java
    Replies: 0
    Last Post: 01-14-2009, 05:37 PM
  3. [SOLVED] Construct parents using tree path.
    By Melki in forum AWT / Swing
    Replies: 2
    Last Post: 09-23-2008, 04:54 PM
  4. How to construct checkbox in rtf document using iText?
    By soumyanil in forum Advanced Java
    Replies: 0
    Last Post: 07-28-2008, 11:05 AM
  5. Replies: 3
    Last Post: 12-05-2007, 02:22 AM

Posting Permissions

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