Since I am new to Java, I need some help about some basic things on Java.
I have two questions. They may be very simple(they are at least in C++), but I couldn’t figure out how to do it in Java.
(i) How to split line with comma separated values into separate strings?
Suppose I have an input(text) file like:
zoo,name,cszoo,address,miami
...,...,...,....
I want to read the input line by line from file and get the strings between commas for each line
(ii) Calling sub class constructor
If I have a superclass called Animal and a subclasses called Dog and Cat. While I read them from input, I put them into a Vector as an Animal. But I need to call their constructor as if they are Dog or Cat. How do I do it in Java
1 Answer