Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to assign values from array to strings java

Hello i have an array that is filled with values from database and those values i want to assign them to strings i did this code but its making error:

        String[] options = s.split(",");
        String visible = options[0];
        String sms = options[1];
        String contact = options[2];
        String calllogs = options[3];

I want the values to separate in array and then by index position to delcare them on each string.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You could use this Technique.

String s = "1000";
  String[] options = new String[s.length()];
  for(int i=0; i< s.length(); i++)
    options[i] = Character.toString(s.charAt(i));

But since you are storing chars the array could be declared as char array

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading