0

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.

6
  • possible duplicate of java : convert float to String and String to float Commented Apr 16, 2014 at 9:11
  • Not possible in one go! in JAVA Commented Apr 16, 2014 at 9:12
  • What is your question? How to format float values into a string or how to get 10 of them into one string? Commented Apr 16, 2014 at 9:12
  • @AleksG get all 10 of them into one format string. Commented Apr 16, 2014 at 9:13
  • 1
    @Alaeddine I want to format all of them into one string. It's not a duplicate question. Commented Apr 16, 2014 at 9:15

2 Answers 2

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

Try this

Sign up to request clarification or add additional context in comments.

Comments

1

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]);
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.