aspose file tools*
The moose likes Beginning Java and the fly likes java array gap type question, i'm really stuck Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java array gap type question, i Watch "java array gap type question, i New topic
Author

java array gap type question, i'm really stuck

salpie Nowinski
Greenhorn

Joined: Apr 11, 2011
Posts: 3
hi there,

so i have this array that is made of 31 classes (i don't even know if you can do that) and each class has 2 strings and 1 integer, but with each of the 31 classes one of each of those strings i want to have a gap in the middle. so here's an example of one class:

so the string i want to have a gap of three characters is: "$TTACCT$3$TGAACT$" so i thought i should use the symbol "$" i guess as a delimiter so i could split it up so there would be a gap, but i'm not sure what i need to say in order for that to happen. sorry if this is very confusing, i am very very new to java. i would really appreciate any help at all. thanks
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
You mean you want to have an array of 31 objects where each object is an instance of a different class? That is only possible if each of those classes inherit from the same class, in which case the array must be of the inhered class type.
For example an array can contain cats and dogs if the array is of type Animal.

Regarding your question about splitting the string, you can use the String method split() for that or iterate through the string cutting one chunk at a time using substring() and indexOf(). You can about String methods here
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40059
    
  28
Unnar Björnsson wrote:. . . That is only possible if each of those classes inherit from the same class, in which case the array must be of the inhered class type. . . .
You could always use an Object[], but what is the point of an array of many objects of different classes?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java array gap type question, i'm really stuck