1. Datalist => notice() 메소드에 원시 배열 게시판 존재
2. notice_list.java 생성 후 해당 java 파일이 메인 Controller
3. notice_DTO.java를 생성하여 해당 원시 배열 값을 클래스 배열로 이관
4. Controller에서 해당 notice 데이터를 출력
[결과] - 최신 게시물이 제일 먼저 나오도록 콘솔로 출력
6. “가장 널리 사용하는 LTS 버전은 자바 17” - infoWorld [2025-01-08]
5. “입문자 ~
4.
3.
2.
1.
데이터
package basic_html;
//각종 데이터 리스트 배열을 가지고 있는 클래스
public class datalist {
public String[][] product() {
String product[][] = { { "솔브리빙 논슬립 내구성 좋은 고급형 옷걸이", "Y", "37000", "30400", "17", "250" },
{ "코끼리리빙 문걸이 전신거울", "Y", "265740", "258120", "2", "310" },
{ "리빙스타 스탠드 행거 트리", "Y", "46700", "35900", "23", "16" },
{ "스피드랙 업그레이드형 홈던트하우스 철제 선반", "N", "35900", "", "", "33" },
{ "보노하우스 슬림서랍장 4단", "N", "30400", "", "", "70" },
{ "보노하우스 맥스 서랍장 2단", "Y", "141000", "54900", "61", "120" },
{ "스피드랙 업그레이드형 홈던트하우스 철제 선반 3단", "Y", "144160", "132740", "7", "44" },
{ "스피드랙 업그레이드형 홈던트하우스 조립식 행거", "N", "30400", "", "", "57" },
{ "리빙스타 모던 스탠드 행거 화이트", "Y", "29900", "23900", "20", "314" } };
return product;
}
public String[][] notice() {
String notice[][] = { { "“가장 널리 사용하는 LTS 버전은 자바 17”", "InfoWorld", "2025-01-08", "146" },
{ "“입문자부터 숙련자까지” 주의해야 할 러스트 프로그래밍 실수 6가지”", "데크플레이션", "2024-12-20", "56" },
{ "ASCII 3D 렌더러 만들기", "IT 뉴스", "2024-12-15", "98" },
{ "깃허브 '코파일럿': 인공지능이 개발자를 대체할 수 있을까?", "BBC News 코리아", "2024-12-03", "41" },
{ "‘펜데믹이 끝이 아니었다’··· IT가 직면한 11가지 이슈", " CIO Korea", "2024-12-03", "33" },
{ "IT 개발자 몸값 더 오를 수밖에 없다", "ZD Net코리아", "2024-12-01", "269" } };
return notice;
}
}
DTO
package basic_html;
import java.util.ArrayList;
public class notice_DTO {
String title, corp, date, recommendation;
ArrayList<String> datamake= null;
ArrayList<ArrayList<String>> alldata = new ArrayList<ArrayList<String>>();
public ArrayList<ArrayList<String>> alldata(){
return this.alldata;
}
public ArrayList<String> datamake(){
this.datamake = new ArrayList<String>();
this.datamake.add(getTitle());
this.datamake.add(getCorp());
this.datamake.add(getDate());
this.datamake.add(getRecommendation());
return this.datamake;
}
public notice_DTO(String arr[][]) {
int w = 0;
ArrayList<String> nd = null;
while(w <arr.length) {
this.setTitle(arr[w][0]);
this.setCorp(arr[w][1]);
this.setDate(arr[w][2]);
this.setRecommendation(arr[w][3]);
nd = this.datamake();
this.alldata().add(nd);
w++;
}
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getCorp() {
return corp;
}
public void setCorp(String corp) {
this.corp = corp;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getRecommendation() {
return recommendation;
}
public void setRecommendation(String recommendation) {
this.recommendation = recommendation;
}
}
Controller
package basic_html;
import java.util.ArrayList;
public class notice_list {
public static void main(String[] args) {
Controller_notice cn = new Controller_notice();
cn.notice_list();
}
}
class Controller_notice{
datalist nl = new datalist();
notice_DTO dto = null;
ArrayList<ArrayList<String>> ndlist = null;
public void notice_list() {
String result[][] = this.nl.notice();
this.dto = new notice_DTO(result);
this.ndlist = this.dto.alldata();
this.print_notice();
}
public void print_notice() {
int i = this.ndlist.size() - 1;
int j = 0;
while (i >= 0) {
System.out.printf(i+1+". ");
System.out.printf(this.ndlist.get(j).get(0));
System.out.printf(" - "+this.ndlist.get(j).get(1)+" ");
System.out.println("["+this.ndlist.get(j).get(2)+"]");
i--;
j++;
}
}
}