Question

Here is my code:

float e[10]=new float[10];

Is there any way to format all the 10 floats into a format string? Maybe something like this in Python:

a=range(10)
print ('#'+'(%f)'*10+'#')%tuple(a)

Is there a method like this in java? I mean getting a string like "#(1.0)(2.0)(3.0)#" for the case of array_size 3.

Était-ce utile?

La solution

float e[10]=new float[10];
System.out.println(Arrays.toString(e));

Try this

Autres conseils

Try this , make a loop to the end of the array and parseFloat to a String msg

 String msg = "";
 float[] e= new float[10];
 for(int i=0;i<e.length();i++){
    msg = msg + Float.parseFloat(e[i]);
 }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top