Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

For that if use the array? Which is the its main function?

 
Gustavo Siqueira
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all!

For that if uses the ARRAY ? Which is the its main function ?
Examples use please.

Thanks by opportunity!

 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15436
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Learn about arrays in The Java Tutorials - Arrays.
 
Gustavo Siqueira
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I read!

See my code:



There was one error. I make with that the code is printed with the FOR, and no as shown in tutorial.
How do that the problem is corrected ?
Thanks!
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fala Gustavo!

Champ, how do you get one element of your array (hint: use the start variable)? And second: verify if you are iterating more than the actual length of your array.
 
Murtaza Lokhandwala
Ranch Hand
Posts: 35
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
replace start <= anArray.length with start < anArray.length
 
Gustavo Siqueira
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you all!
Very good!
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fala Gustavo! Tudo bem?

So, were you able to make it work? Can you show us your final code?
 
fred rosenberger
lowercase baba
Bartender
Posts: 12181
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm guessing your code still doesn't quite do what you want.

In fact, It gives me a compilation error. Remember than an array is a CONTAINER of things, not the things themselves. If you had an egg carton full of eggs, you don't try and put the carton into your cake batter, but some of the things inside the container.
 
Gustavo Siqueira
Ranch Hand
Posts: 97
C++ Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Grateful by response!
The problem resolved!
Thanks you all of JavaRanch!

 
Campbell Ritchie
Sheriff
Pie
Posts: 49733
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A nearby thread suggests another way to create your arrayThe new int[] bit and the , shown in the /* */ comment are optional. If you don't have the declaration on the same line, then the new int[] bit becomes compulsory.
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In this case a loop is also an easy way, as there is a pattern between the indexes and the values:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic