0

How to convert an String array to a float array? For example:

String[] arr = new String[] {"1.1","2.2","3.3","4.4","5.5"};

At the end it should be a float array.

3
  • @jhamon does this work also for arrays Commented Apr 19, 2022 at 10:27
  • It works for array elements. You will need to create resulting array yourself and fill it with results of method mentioned in duplicate. Commented Apr 19, 2022 at 10:32
  • 1. Create a float[] with the same length as arr. 2. Iterate arr. 3. Use Float.parseFloat(String s) on every string. 4. Add the result to the float array. Commented Apr 19, 2022 at 11:00

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.