Create a list of String[], in each String[] the last char of an element must be the first char of the next element

I have a String[] { “honorifi”, “cabilitudi”, “nitatibus”, “antidisestab”, “lishmenta”, “rianism”, “floccinau”, “cihihilipil”, “ification”, “supercalifrag”, “ilisticexpia” }

I expect an output is array of string[]. In each array, the last char of this element will equal to the first char of the next element. The output must be like this:

["honorifi", "ification", "nitatibus", "supercalifrag"]
["honorifi", "ilisticexpia", "antidisestab"]
["cabilitudi", "ification", "nitatibus", "supercalifrag"]
["cabilitudi", "ilisticexpia", "antidisestab"]
["nitatibus", "supercalifrag"]
["lishmenta", "antidisestab"]
["cihihilipil", "lishmenta", "antidisestab"]
["ification", "nitatibus", "supercalifrag"]
["ilisticexpia", "antidisestab"]

However, my code misses some cases of result.

[honorifi, ification, nitatibus, supercalifrag]
[cabilitudi, ification, nitatibus, supercalifrag]
[nitatibus, supercalifrag]
[lishmenta, antidisestab]
[cihihilipil, lishmenta, antidisestab]
[ification, nitatibus, supercalifrag]
[ilisticexpia, antidisestab]

Please review my code and help me to correct it. Thank you so much

static String[] test;

public static void main(String[] args) throws java.lang.Exception {
	// your code goes here
	test = new String[] { "honorifi", "cabilitudi", "nitatibus", "antidisestab", "lishmenta", "rianism", "floccinau", "cihihilipil", "ification", "supercalifrag", "ilisticexpia" };

	ArrayList<ArrayList<String>> data = new ArrayList<ArrayList<String>>();

	for (String string : test) {
		ArrayList<String> suite = sortSmartly(string);

	for (ArrayList<String> arrayList : data) {

public static ArrayList<String> sortSmartly(String text) {
	ArrayList<String> result = new ArrayList<String>();
	String lastChar = text.substring(text.length() - 1);
	for (String object : test) {
		String firstChar = object.substring(0, 1);
		if (lastChar.equals(firstChar)) {
	return result;