• Post Reply Bookmark Topic Watch Topic
  • New Topic

Array of Object  RSS feed

 
Pradeep Selvaraj
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any one plz advice me how to create an array of objects.I tried to create the objects but in vain...the code i wrote is..
Customer[] newCustomer = new Customer[20];
newCustomer[0] = new Customer ("pradeep","456 DEF","prad@143.com","prad");
newCustomer[1] = new Customer("Schumi","Ferrari","schumi@ferrari.com","red");
newCustomer[2] = new Customer("Hahn","Beer AV","hahn@vb.com","vb");
I try to create 20 cutomer objects and populating the fields but...i get errors like these
\Login.java:25: ']' expected
newCustomer[0] = new Customer ("pradeep","456 DEF","prad@143.com","prad");
^
.\Login.java:25: <identifier> expected
newCustomer[0] = new Customer ("pradeep","456 DEF","prad@143.com","prad");
^
.\Login.java:25: cannot resolve symbol
symbol : class newCustomer
location: class Login
newCustomer[0] = new Customer ("pradeep","456 DEF","prad@143.com","prad");
^
Note: .\Login.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
3 errors
Thanx in advance
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you've shown here looks fine. Did you cut-and-paste this from your source code, or retype it? It looks as though in your actual source code, the closing brace of the expression "new Customer[20]" may be missing.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!