Declare an array named a of * ten* elements of type int and initialize the elements (starting with the first) to the values 10 , 20 , ..., 100 respectively.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Declare an array named a of * ten* elements of type int and initialize the elements (starting with the first) to the values 10 , 20 , ..., 100 respectively.
What have you tried? Where are you stuck?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
int a [10] = {10,20,30,40,50,60,70,80,90,100};
And what does that do?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
It returns an error.
What is the error?
Recommended reading: Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)
Like we said in your other post, the basic tutorials are your best friend.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Not when I am trying to complete an assignment. Thanks for your help.
Especially when you're trying to complete an assignment.
As a side note, you can either initialize an array to a given size or to what it starts with, not both at the same time.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Because looking at the tuorial is more of a foreign language than being on this board. I do not understand any of it. I checked the tutorials before joining this site. This was my last resort.
take out the 10 in side the brackets and it should be fine
Thanks so much, if you get a chance , could you send me a link to a java beginners site or a java for dummies website?
Assignments usually means time-pressure. Taking that into account, here is the answer:
int[] a = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
That makes an array of ten int-numbers. 10 to 100.
If you want to test it out for yourself, this little code will print out everything:
for (int i = 0; i < a.length; i++) System.out.println(a[i]);
Hope it helped.
EDIT (You got the answer already, but i wanted to illustrate it for clarity^^)
copeg (November 13th, 2011), KevinWorkman (November 13th, 2011)
Given the fact that the tutorials solve a problem which is identical to yours but a factor of 10 out, makes me wonder whether your assignment was to actually read the documentation.
If that is a foreign language to you, then parhaps you should re-consider programming. All programming relies around the ablility to read documentation/man pages on a subject you do not know and make sense of it.
Trying reading just over half way down the page linked above by Kevin
KevinWorkman (November 13th, 2011)