This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes array question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "array question" Watch "array question" New topic

array question

Scott Pocane

Joined: Nov 03, 2003
Posts: 2
ok if i want 3 different ellements in one array how would i go about doing that.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183

What do you mean by three different elements? Three different kinds of objects? You can use an Object array to hold any kind of objects, like
Object[] myArray = { "A string", Color.RED, new Point(1, 2) };
But if you're going to count on a certain object being in a certain position (and I know that's what you're going to do!) then don't use an array -- define a new class to hold the objects as member variables.

[Jess in Action][AskingGoodQuestions]
It is sorta covered in the JavaRanch Style Guide.
subject: array question
Similar Threads
how many objects will be created.
Multi Dimension Array Storing
WA #1.....word association
Sorting an Array
Widening Reference Conversation