How to find the triplet numbers from an array whose sum is divisible by 9

This is the first solution to find the triplet of numbers in which their sum is divisible by 9 from an array of integers. This method uses the core logic of traversing array using nested for loop, add any three successive numbers in each iteration, and then verify that sum divisible by 9.

import java.util.ArrayList;
import java.util.List;

public class SumtripletsDivby9 {

	public static List<Integer> divby9(int[] tempArr) {

		List<Integer> answerTriplets=new ArrayList<Integer>();

		System.out.println("The hardcoded array of integers given below");
		System.out.print("[ ");
		for(int i=0;i<tempArr.length;i++)
			System.out.print(tempArr[i]+" ");
		System.out.println("]");
		//Traverse through the array using nested for loop, and check whether the sum of the any three successive numbers divisible by 9
		for (int i=0;i<tempArr.length;i++) {
			for(int j=i+1;j<tempArr.length;j++) {
				for(int k=j+1;k<tempArr.length;k++) {
					int sum = tempArr[i]+tempArr[j]+tempArr[k];
					if (sum%9==0) {
						answerTriplets.add(tempArr[i]);
						answerTriplets.add(tempArr[j]);			
						answerTriplets.add(tempArr[k]);
					}		
				}	
			}
		}
		return answerTriplets;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[] intArr= {14,20,11,5,29,17,58};
		System.out.println("OUTPUT:");

		//Calling the function divby9 which computes the sum of triplets divisible by 9
		List<Integer> retTriplets=divby9(intArr);

		System.out.println("The Triplets of numbers which are divisible by 9");
		for(int i=0;i<retTriplets.size();i+=3)
			System.out.println(retTriplets.get(i)+"    "+retTriplets.get(i+1)+"    "+retTriplets.get(i+2));
	}
}
OUTPUT:
 The hardcoded array of integers given below
 [ 14 20 11 5 29 17 58 ]
 The Triplets of numbers which are divisible by 9
 14    20    11
 14    20    29
 14    11    29
 14    5    17
 20    11    5
 20    5    29
 11    5    29