```
public class Solution {
public int threeSumSmaller(int[] nums, int target) {
Arrays.sort(nums);
int total = 0;
for(int i=0; i<nums.length;i++) {
int j = i+1;
int k = nums.length -1;
while(j<k) {
if(nums[i]+nums[j]+nums[k] < target) {
total += (k-j);
j++;
} else {
k--;
}
}
}
return total;
}
}
```