package ch05;

public class Ch0508
{
 //멤버함수 오버로딩 : 멤버함수를 선언할 경우
 //인자의 갯수가 다르면 별개의 함수로 취급하는
 //이 특성을 오버로딩이라 부른다.
 public Ch0508()
 {
  // TODO 자동 생성된 생성자 스텁
  hello();
  hello("비가 오는 날");
  int z = hello(1,2);
  System.out.println(z);
 
 }

 public void hello()
 {
  System.out.println("Hello");
 }
 
 public void hello(String s)
 {
  System.out.println(s);
 }
 
 public int hello(int a, int b)
 {
  return a+b;
 }
 
 public Ch0508(String s)
 {
  System.out.println("생성자메시지 : "+s);
 }
 
 public static void main(String[] args)
 {
  //생성자도 오버로딩가능.
  //new Ch0508();
  new Ch0508("hello");
 }
}

Posted by 말없제이
,