File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 24199

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]
I agree. Here's the link:
subject: array question
It's not a secret anymore!