2
I have to implement an array that is capable of storing objects of any kind. For example: V[3]= valor_int,valor_double,valor_float,valor_String
. To do this I was thinking of creating a method that parses the values I want to insert, would be the best way out of this case?
vetor v = new Object[3];
or if you can use Collections:ArrayList list = new ArrayList<>();
– user28595
You need to go into more detail to know.
– Maniero
@Diegof Thanks for the tip, I had not thought this way, I was going to create a parse method that was going to make the data conversion but this was going to run away from the proposed theme, Thank you I will try here.
– user46438
@bigown The problem is this, I have to create an array that accepts any data I put can be a String,int and a float or String, Int, String, for example. The way I initially thought to solve the problem was to make a method that converted the variables, and my question was whether I had a better way to do it or could do it by parse.I don’t know if I explained it better?
– user46438
No, you repeated what was already in the question. If you can convert, convert and do not worry about having to accept any type. If you can’t convert, this way doesn’t work and needs another, but you need to better understand the problem.
– Maniero
@Sorry Bigown, I’ll put the order of the exercise, all of a sudden it gets clearer. Exercise Order : Create an array, which is capable of storing objects of any type. My solution was to use parse, but I realized this would not meet the needs of the exercise.
– user46438
Is this the whole statement of the exercise? What is in the question is only your assumption?
– Maniero
Yes the order of the exercise is just this: Create a vector, which is able to store objects of any type.
– user46438