I have a problem with casting a variable (see below) to a String so that it can be displayed in a GUI. Some background information: I have created a Java GUI that will run some Matlab code (using MatlabProxy) and as part of the process I am trying to update the GUI with some useful information (passed back to the GUI from Matlab) about a specific data file (that the user has chosen). The MatlabProxy “getMVariable()” function returns an object of type “double” (in my case); however, when I try to cast this to a String using
String text = (String) getMVariable("testInfo.freqMax");
I get the ClassCastException: “[D cannot be cast to java.lang.String.” I also tried casting it to a String array (String[]) with no luck. I’ve read some posts that say something about using Array.copyOf or something about an array list, but could not make sense of it.
[Dmeans it’s adouble[]. SeeClass#getName().After that, it’s up to you to figure out what to do with it.