• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 33
Eclipse IDE Flex Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More than enough, thank you all
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, on a stylistic note, Java conventions put the array brackets in a different location:
 
reply
    Bookmark Topic Watch Topic
  • New Topic