관리 메뉴

nalaolla

오브젝트 예제 3 (게시판 객체생성 및 출력) 본문

JAVA/7. Object3

오브젝트 예제 3 (게시판 객체생성 및 출력)

날아올라↗↗ 2016. 6. 22. 17:17
728x90
  1. package test.com;
  2.  
  3. import java.util.Date;
  4.  
  5. public class Test03Board {
  6.     int num;
  7.     String title;
  8.     String content;
  9.     String name;
  10.     Date regDate;
  11.  
  12.     public Test03Board() {
  13.         num++;
  14.         title = "title";
  15.         content = "content";
  16.         name = "name";
  17.         regDate = new Date();
  18.     }
  19.  
  20.     public Test03Board(int num, String title, String content, String name) {
  21.         this.num = num;
  22.         this.title = title;
  23.         this.content = content;
  24.         this.name = name;
  25.         this.regDate = new Date();
  26.        
  27.     }
  28. }




  1. package test.com;
  2.  
  3. public class Test03BoardMain {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.        
  8.         System.out.println("Board...");
  9.        
  10.         //게시판 객체생성 및 출력
  11.         Test03Board b01 = new Test03Board();
  12.         System.out.println(b01.num);
  13.         System.out.println(b01.title);
  14.         System.out.println(b01.content);
  15.         System.out.println(b01.name);
  16.         System.out.println(b01.regDate);
  17.        
  18.         Test03Board b02 = new Test03Board(0"title1""content1""KIM");
  19.         System.out.println(b02.num);
  20.         System.out.println(b02.title);
  21.         System.out.println(b02.content);
  22.         System.out.println(b02.name);
  23.         System.out.println(b02.regDate);
  24.        
  25.     }
  26.  
  27. }


728x90