aspose file tools*
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
Author

array question

Scott Pocane
Greenhorn

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
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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]
 
 
subject: array question