shivmaruti singh wrote:yes i have classes career id and path id, program id,
Those don't sound right to me, but from looking at your code, I suspect its just the names that are wrong.
An 'ID' is simply an identifier, so it's probably just an integer or a code of some sort.
What
you want is a
Career (or
Path, or
Program) object that contains ALL the things related to
a single Career (or
Path, or
Program).
Now maybe that's what you have, but you still haven't shown us what they look like. Just so we don't get inundated, show us the code for
one of them: eg,
PathID, and then we can go from there.
You've also introduced something new - a '
dao' object - which you didn't tell us about (but I suspected was there all along

), viz:
List<CareerId>list2=dao.combination(p1, p3, p2);
However, things are looking a lot better now, so I can advise you on a few things:
1. Use
"for-each" loops (I think the official name is "enhanced" for loop) when iterating
Lists. They're much simpler, viz:
instead of:
2. Have your methods
return a
List istead of trying to link them all together externally, eg:
private List<PathId> eightCombination(List<CareerId> list8) {
instead of:
private void eightCombination(List<CareerId> list8) {
Then your methods will be a lot more self-contained.
3. Have each method take a
single object, not a List. Ie:
private List<PathId> eightCombination(CareerID career) {
instead of:
private List<PathId> eightCombination(List<CareerId> list8) {
Then your implementation might be as simple as:
the only difference is that you'd have to call it once for each
CareerID object and aggregate the returned
PathIDs into a single
List, viz:
Do you see how it works? You could even write a method to do
that (the aggregation) if you want.
Right now you're making your methods do far too much at once, and because they all return
void, you have no way of connecting them together (at least, not easily).
Remember:
One method, one - and ONLY one - task.Never write a method that returns a void if it can usefully return something else.
In your case, ALL your methods can return a List of whatever they're trying to collect, and you can worry about the business of connecting/aggregating them later.
HIH
Winston