/* package whatever; // don't place package name! */
import java.util.* ;
import java.lang.* ;
import java.io.* ;
import java.text.* ;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
String [ ] myArray
= { "Turma A" ,
"Turma B" ,
"Turma C" } ; List
< String
> arrayList
= new ArrayList
< String
> ( Arrays .
asList ( myArray
) ) ;
Date dt1
= df.
parse ( "01/10/2016" ) ; // Data inicial Date dt2
= df.
parse ( "10/10/2016" ) ; // cal1.setTime ( dt1) ;
cal2.setTime ( dt2) ;
//cria o iterator sob o arraylist
Iterator< String> it = arrayList.iterator ( ) ;
for ( Calendar cal
= cal1
; cal.
compareTo ( cal2
) <= 0 ; cal.
add ( Calendar .
DATE ,
1 ) ) { //checa se o iterator já chegou ao fimm
//se sim, o reinicia
if ( ! it.hasNext ( ) ) {
it = arrayList.iterator ( ) ;
}
// next() exibe o item seguinte do arraylist
System .
out .
println ( df.
format ( cal.
getTime ( ) ) + " " + it.
next ( ) ) ; }
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnRleHQuKjsKCi8qIE5hbWUgb2YgdGhlIGNsYXNzIGhhcyB0byBiZSAiTWFpbiIgb25seSBpZiB0aGUgY2xhc3MgaXMgcHVibGljLiAqLwpjbGFzcyBJZGVvbmUKewoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CiAgICAgICAgU3RyaW5nW10gbXlBcnJheSA9IHsiVHVybWEgQSIsICJUdXJtYSBCIiwgIlR1cm1hIEMifTsKICAgICAgICBMaXN0PFN0cmluZz4gYXJyYXlMaXN0ID0gbmV3IEFycmF5TGlzdDxTdHJpbmc+IChBcnJheXMuYXNMaXN0K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