The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
June 2000



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


arrays declaration at class lever(member arrays)

Posted by Y V NANCHARAIAH on June 14, 2000 at 9:00 AM

Dear Programmers
I faced a small problem in compiling a small java program during my scjp preparation. I have declared an single dimentional array at class level and tried to allocate memory in the next statement using new operator. but it is giving compile time error, identifier expected. i could do same thing in a method without any errors. i could also declare it at class level and
allocate memory in the constructor with out any problem
code fragement:
class ArrayDecl{
int ints[];
ints = new int(5); //error
public static void main(String args[]){
pl send me the reason why it is giving compile time error.
thanking you.



Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us