• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using arrays to declare name and address  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Trying to use arrays to declare name/address and to populate it


 
Saloon Keeper
Posts: 4068
48
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see an array declared anywhere (?). Do you know how to declare an array?

Also, when you post code you need to enclose it in "Code" tags. Above the edit window are some buttons, one of which is Code. First highlight your code, then click that button.
 
Joshua Perrine
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to declare an array confused on how to here
 
Carey Brown
Saloon Keeper
Posts: 4068
48
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To declare an array of int's
The first "[]" says we are declaring an array, and the "[ 10 ]" allocates room for 10 int's'.

You have
You could make each one an array but you'd be asking for trouble trying to keep them in sync.
The best approach is to define a class (e.g.) Person with those fields. and then allocate one array of Person objects.
 
Joshua Perrine
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
still confused on how to implement this into my code.
 
Carey Brown
Saloon Keeper
Posts: 4068
48
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest you Google "java array tutorial" and study some of those. This TUTORIAL looked good. I also suggest writing some very small programs to practice, put your current project aside for now.

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to declare the array, that's why you're getting errors. Hope this helped!
 
Sheriff
Posts: 4756
133
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you post, be sure it adds something to the thread.  This advice was already given.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!