Note that there are some explanatory texts on larger screens.

plurals
  1. POArray of Strings to an Array of Objects
    primarykey
    data
    text
    <p>Maybe there is a method that does this that I don't know about - I doubt it though - but I'm trying to convert an array of strings to an array of Objects. Here is the problem: I'm reading a file in from the command line. The file represents several classes of the following types each with their own data fields. Vehicle is the parent class of all who follow: Vehicle,Car,American Car, Foreign car, Truck, Bicycle. </p> <p>I have no problem reading the file into a string array. However I need to create objects of all these types and store them in an array of type Vehicle[]. For example a portion of the file looks like this:</p> <ul> <li>Vehicle</li> <li>Kim Stanley Robinson</li> <li>2344 court drive</li> <li>(221)885-7777</li> <li>stackoverflow@overflow.com</li> </ul> <ul> <li>American Car</li> <li>John Bunyon</li> <li>1010 binary lane</li> <li>(221)885-55643</li> <li>bgt.com</li> <li>convertable</li> <li>made in detroit</li> <li> union plant</li> </ul> <p>Where Class type is the first line followed by, Owner's Name, address, phone number, email address...Each type has fields particular to it. So a foreign car is not made in Detroit. Each of these fields appear on a separate line in the file. So what I've done is read the entire file into a string array. However, I need to find my types in the array of strings,create objects of those types, and store them in a Vehicle array. My main problem is that each data field is on a separate line. How should I approach this problem? This is java code by the way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload