Home > Back-end >  To give every child objects in an object of a certain attribute assignment, in addition to the cycle
To give every child objects in an object of a certain attribute assignment, in addition to the cycle

Time:09-15

//set forexId
Forexes. ForEach (forex - & gt; {
List ForexItemList=forex. GetForexItemList ();
ForexItemList. ForEach (forexItem - & gt; {
ForexItem. SetForexId (forex getId ());
});

ForexItems. AddAll (forexItemList);
});

CodePudding user response:

Double loop feeling so low

CodePudding user response:

Cycle is inevitable, can change the wording,

Code to facilitate understanding, execution efficiency is higher,
Where is the double loop low? I don't understand.
Is not complicated code must be good, or, a very simple things, make complicated code, is clever, this call talks over my head,

CodePudding user response:

refer to the second floor ice rain reply:
cycle is inevitable, can change the wording,

Code to facilitate understanding, execution efficiency is higher,
Where is the double loop low? I don't understand.
Is not complicated code must be good, or, a very simple things, make complicated code, is clever, this call mystifying,

Double loop is a waste of memory

CodePudding user response:

Someone will think of 100 copies of a piece of and a 100 is not equal,

We write in a stream java8, of course, the stream when data volume is larger than the for loop is fast

CodePudding user response:

reference 3/f thousand night dream response:
Quote: refer to the second floor ice rain reply:
cycle is inevitable, can change the wording,

Code to facilitate understanding, execution efficiency is higher,
Where is the double loop low? I don't understand.
Is not complicated code must be good, or, a very simple things, make complicated code, is clever, this call mystifying,

Double loop so waste memory

Don't know how you to this conclusion, which come of the waste of memory? Object on the heap, stack memory out of the scope is released, don't know where is wasted.

CodePudding user response:

Just let you avoid redundant loop, not to say that can't use double loop,
Because of the double loop computation is product, so should pay more attention to, to use cycle of internal logic should as far as possible concise.
  • Related