0

I have a string like this:

String ColorCodes = "colorcodes:#FFOOFF,#OOACOF,#EEAAAA"

I want to get the three color codes in the above string into three different strings, like this:

String ColorOne = "#FFOOFF"
String ColorTwo = "#OOACOF"
String ColorThree = "#EEAAAA"

How can I do this?

Changer
  • 351
  • 1
  • 3
  • 12

1 Answers1

1

You can use substringand split:

    String[] colors = colorCodes.substring(colorCodes.indexOf(":") + 1).split(",");
            
    System.out.println(Arrays.toString(colors));

Output

[#FFOOFF, #OOACOF, #EEAAAA]
Oboe
  • 2,643
  • 2
  • 9
  • 17