728x90
import java.util.ArrayList;
import java.util.List;
public class SujeongTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
SujeongTest sujeongTest = new SujeongTest();
List<String> stringList = sujeongTest.makeStringList();
String printValue = "";
int listSize = stringList.size();
int countRow = 1;
int sIdx = 0;
int eIdx = sujeongTest.getLastIndex( countRow , listSize) ;
while( sIdx < listSize ){
for(String string : stringList.subList(sIdx, eIdx)){
printValue = printValue.concat(string).concat(" ");
}
printValue = printValue.trim().concat("\n");
sIdx = eIdx;
eIdx = sujeongTest.getLastIndex(++countRow , listSize);
}
System.out.println(printValue);
}
private int getLastIndex(int countRow , int listSize) {
int countColumn = 4;
int endIndex =(countRow * countColumn);
if(listSize <= endIndex) {
endIndex = listSize;
}
return endIndex;
}
private List<String> makeStringList(){
List<String> stringList = new ArrayList<String>();
stringList.add("1.AAAAA");
stringList.add("2.BBBBB");
stringList.add("3.CCCCC");
stringList.add("4.DDDDD");
stringList.add("5.EEEEE");
stringList.add("6.FFFFF");
stringList.add("7.GGGGG");
stringList.add("8.HHHHH");
stringList.add("9.IIIII");
stringList.add("10.JJJJJ");
stringList.add("11.KKKKK");
return stringList;
}
}
'Dev' 카테고리의 다른 글
jQuery Datepicker 랜더링 (0) | 2017.07.06 |
---|---|
Codility Demo Task Solving (0) | 2016.01.24 |
Difference between start and run method in Thread in Java (0) | 2015.08.07 |
Maven Build lifecycle and POM version SNAPSHOT (0) | 2015.02.28 |
Windows XP 탐색기에서 이미지 미리보기 제거 (0) | 2013.01.27 |