Log in

View Full Version : getNumberArray(String) is deprecated


Jeringo
25-03-2016, 20:51
I am trying to get an array value from network tables in java but can't seem to get it right.
currently using this...
double[] width = Table.getNumberArray("width");
but I am getting this
The method getNumberArray(String) from the type NetworkTable is deprecated
how would I fix this?

nighterfighter
25-03-2016, 22:17
Deprecated methods means that they are old or may no longer be supported/may be removed in a future update.

However, they should still work. I assume you aren't getting an error, but rather a warning.




As for fixing it: You'd have to use the new way of doing what you are trying to do. I don't know what it is called off the top of my head.

soundfx
25-03-2016, 22:59
You'd have to use the new way of doing what you are trying to do. I don't know what it is called off the top of my head.

This new method allows you to set a default value as a second parameter to return if no value can be found. The new method is getNumberArray(String key, Double[] defaultValue).

Jeringo
25-03-2016, 23:42
This new method allows you to set a default value as a second parameter to return if no value can be found. The new method is getNumberArray(String key, Double[] defaultValue).

after using

double[] defaultval = new double[0];
getNumberArray("width", defaultval );
it says defaultval is a double but it needs to be a double[]
forgive me if im missing something very obvious switched over to java 4 days ago and arrays are not my strong suit

nighterfighter
25-03-2016, 23:44
after using
getNumberArray("width", double[] 0.0)
i get a misplaced constructs on double[]

Try this:

Double[] x = {0.0};

getNumberArray("width", x);

Jeringo
26-03-2016, 00:06
Try this:

Double[] x = {0.0};

getNumberArray("width", x);

this worked thank you