This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Arrays" Watch "Arrays" New topic


Mwenya Chongo

Joined: Dec 15, 2010
Posts: 10
Hi. am new at Java and am just teaching myself. I hope through the forums I will able to gather as much help and advise. To day I want top know how to declare an array in a class outside the main method. And how to declare the array in the constructor.

I hope am not being too... "£$%%^^&**((). This will be my starting point.

Thank you very much
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32301

Do you know how to declare an array inside a method?

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Colm Dickson
Ranch Hand

Joined: Apr 04, 2009
Posts: 89
The folowing is a good link. Arrays can be declares with a certain size and the you can explicitly assign values to each element or you can declare and assign values in one go using the curly braces as can be seen in the following link

subject: Arrays
It's not a secret anymore!