Man
package com.mywork.ex;
public class Man {
String name;
int age;
final static char GENDER = '남';
Man(String name, int age){
this.name = name;
this.age = age;
}
void output() {
System.out.println("성명 : " + name);
System.out.println("나이 : " + age);
System.out.println("성별 : " + GENDER);
}
}
ManMain
package com.mywork.ex;
public class ManMain {
public static void main(String[] args) {
Man man = new Man("홍길동", 20);
man.output();
System.out.println(man.name);
System.out.println(man.age);
System.out.println(man.GENDER);
System.out.println(Man.GENDER);
}
}
StaticSample
package com.mywork.ex;
import javax.swing.JOptionPane;
public class StaticSample {
public static void main(String[] args) {
System.out.println();
JOptionPane.showInputDialog("입력메시지");
JOptionPane.showMessageDialog(null, "출력메세지");
System.out.println(Math.PI);
}
}
Team
package com.mywork.ex;
public class Team {
String name;
static int count;
Team(String name){
this.name = name;
count++;
}
void output() {
System.out.println("이름 : " + name);
System.out.println("현재 팀원 : " + count + "명");
}
}
TeamMain
package com.mywork.ex;
public class TeamMain {
public static void main(String[] args) {
Team member1 = new Team("홍길동");
Team member2 = new Team("홍길순");
member1.output();
member2.output();
System.out.println("전체 팀원 : " + Team.count);
}
}