java - Having a trouble getting List of Strings from array.xml file and parsing them to array of floats android -


getting strings array file , parsing them array of float numbers. once run code null pointer exception array not empty. help... code inside oncreate method:

    string[] lat = getresources().getstringarray(r.array.latitudes);      list<float> latitudes = new arraylist<>();         (string l : lat) {             latitudes.add(float.parsefloat(l));         } 

the code inside array.xml file:

<?xml version="1.0" encoding="utf-8"?> <resources>  <array name="latitudes">     <item >51.885375</item><!-- cit main campus -->     <item >51.884774</item><!-- library -->     <item >51.884966</item><!-- nexus student centre -->     <item >51.885651</item><!-- admin office -->     <item >51.883761</item><!-- canteen -->     <item >51.884694</item><!-- stadium -->     <item >51.884721</item><!-- gym -->     <item >51.884642</item><!-- car park -->     <item >51.886531</item><!-- melbourne exam hall -->     <item >51.895137</item><!-- cit crawford college of art , design -->     <item >51.896025</item><!-- cit cork school of music --> </array>  <array name="longitudes">     <item >-8.534452</item><!-- cit main campus -->     <item >-8.534278</item><!-- library -->     <item >-8.535195</item><!-- nexus student centre -->     <item >-8.533758</item><!-- admin office -->     <item >-8.533522</item><!-- canteen -->     <item >-8.537159</item><!-- stadium -->     <item >-8.534777</item><!-- gym -->     <item >-8.538809</item><!-- car park -->     <item >-8.533832</item><!-- melbourne exam hall -->     <item >-8.481826</item><!-- cit crawford college of art , design -->     <item >-8.468063</item><!-- cit cork school of music --> </array>  </resources> 

stacktrace

try use string-array instead of array


Comments

Popular posts from this blog

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

java - Could not locate OpenAL library -

sorting - opencl Bitonic sort with 64 bits keys -