This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How can we declare and use array as staitc if arrays are objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How can we declare and use array as staitc if arrays are objects" Watch "How can we declare and use array as staitc if arrays are objects" New topic
Author

How can we declare and use array as staitc if arrays are objects

raul saini
Greenhorn

Joined: May 18, 2010
Posts: 18
In the code below, how can we declare array as static if, In java arrays are objects?

"Also Please clear my doubt from this if we can create objects of static"



Thank You
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Welcome to Java ranch

In java arrays are objects?


Yes In java arrays are objects.

"Also Please clear my doubt from this if we can create objects of static"


I really didn't get what are you want to say


Life is easy because we write the source code.....
Rajesh Tarte
Ranch Hand

Joined: Nov 02, 2006
Posts: 33

Declaring static fields in any class means those varibles can be accessed without instatiating object of that class.
Example
Class MyClass{

static declaration including objects or array or primitive..
}

Static varible does not mean that you do not instantiate it.It means you do not require to instatiate the class in which they are declared however you need to create a object of that whether that variable is declared static or not...

Do you require more clarification?
or you got it?


SCJP 1.5 | SCWCD 5.0 |SCBCD
raul saini
Greenhorn

Joined: May 18, 2010
Posts: 18
More than enough, thank you all
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37902
    
  22
Why do you want that array to be static? Or are you simply trying it out to see what happens?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Also, on a stylistic note, Java conventions put the array brackets in a different location:
 
 
subject: How can we declare and use array as staitc if arrays are objects
 
Similar Threads
Question about multidimensional arrays
Array declaration
java arrays
three or four array by declartion like this?
doubt in Array construction