• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
raul saini
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rajesh Tarte
Ranch Hand
Posts: 33
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
raul saini
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
More than enough, thank you all
 
Campbell Ritchie
Sheriff
Pie
Posts: 49823
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you want that array to be static? Or are you simply trying it out to see what happens?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, on a stylistic note, Java conventions put the array brackets in a different location:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic