Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

break Statements and flag  RSS feed

 
swetha deshmukh
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There r 3 arraylists ate1,date2,infoname and info.
my code is

here infoname is repeating i want it only once
can anyone help in writing the code?I guess flag has be given ...

(Marilyn added code tags)
[ September 17, 2005: Message edited by: Marilyn de Queiroz ]
 
Norm Radder
Ranch Foreman
Posts: 2240
28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>here infoname is repeating i want it only once

I assume you are talking about the execution of:
System.out.println(infoname[j]);

What defines 'only once'? Is that the first time? Like when the index value(s) are at 0?
Or only the first chance it can be executed?
You could use a boolean oneTime switch that you test and set.
if not set {
set
execute
}
 
Jayesh Lalwani
Ranch Hand
Posts: 502
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need the outer loop?. Because of the outer loop, infoname should be printed date1.length number of times
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!