Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / December 2004

Tip: Looking for answers? Try searching our database.

Variable alCustomerRecords might not have been initialized

Thread view: 
Kurt Harless - 12 Dec 2004 21:16 GMT
Greetings,

Still getting the hang of Java.

What am I doing wrong here?

import java.util.*;
public class DriveForm
{

   public static void main(String[] args)
   {
       ArrayList alCustomerRecords;
       InitArray(alCustomerRecords);     <--- this is line 8
  //     panel2 mypanel2 = new panel2(alCustomerRecords);
  //     mypanel2.show();
   }

   public static void InitArray(ArrayList lalCustomerRecords)
   {
       lalCustomerRecords.add(new Customer("Alexandria","ALX"));
       lalCustomerRecords.add(new Customer("Archways","ARC"));
    }
}

Get this error;

DriveForm.java [8:1] variable alCustomerRecords might not have been
initialized
       InitArray(alCustomerRecords);
                 ^
1 error
Errors compiling DriveForm.
Brett Foster - 12 Dec 2004 21:38 GMT
*snip*
>         ArrayList alCustomerRecords;
          alCustomerRecords = new ArrayList();
>         InitArray(alCustomerRecords);     <--- this is line 8
*snip*
klynn47@comcast.net - 13 Dec 2004 07:24 GMT
Java requires that any local variable be initialized before it is used.
This is not true for instance or class variables. They will be
initialized to defaults if you don't initialize them in a constructor.
But for a local variable you must initialize it before you use it.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.