aspose file tools*
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
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: 38340
    
  23
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