The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
June 2000

Advertisement

Advertisement

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.

Message:

Re: arrays declaration at class lever(member arrays)

Posted by Poorani on June 16, 2000 at 5:20 PM

In class definition, only declarations will be handled outside the methods. But if you do not want a named method, you could define a code block as shown below, which avoids the error.

class ArrayDecl{
int ints[];
{ // fix for error
ints = new int(5);
}
public static void main(String args[]){
System.out.println("OK");
}
}




Replies:

Sponsored Links



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