Coding/Java 삽질기2012. 10. 7. 02:56



'Coding > Java 삽질기' 카테고리의 다른 글

이클립스 실행 오류  (0) 2012.11.15
ChoboCalendar V0.15  (0) 2012.07.12
Android Notification 달력  (0) 2012.07.03
Posted by chobocho
Coding/Java 삽질기2012. 7. 12. 02:40



'Coding > Java 삽질기' 카테고리의 다른 글

ChoboCalendar V0.16  (0) 2012.10.07
Android Notification 달력  (0) 2012.07.03
[Android] Image match game ( V 0.21 )  (0) 2011.10.25
Posted by chobocho
Coding/Java 삽질기2012. 7. 3. 03:38


그냥 만들어 본, 안드로이드용 Notification 달력...



'Coding > Java 삽질기' 카테고리의 다른 글

ChoboCalendar V0.15  (0) 2012.07.12
[Android] Image match game ( V 0.21 )  (0) 2011.10.25
[Android] Image match game ( V 0.2 )  (0) 2011.09.12
Posted by chobocho
Coding/Java 삽질기2011. 10. 25. 01:50


'Coding > Java 삽질기' 카테고리의 다른 글

Android Notification 달력  (0) 2012.07.03
[Android] Image match game ( V 0.2 )  (0) 2011.09.12
Press a ghost  (0) 2011.09.01
Posted by chobocho
Coding/Java 삽질기2011. 9. 12. 01:08


'Coding > Java 삽질기' 카테고리의 다른 글

[Android] Image match game ( V 0.21 )  (0) 2011.10.25
Press a ghost  (0) 2011.09.01
Java 실행 시간 측정 하기  (0) 2011.09.01
Posted by chobocho
Coding/Java 삽질기2011. 9. 1. 23:23


지인이 만든 게임을 보고 따라서 만들어 보았다.

초 간단 규칙, 발바닦으로 얼굴을 문질러 주면 된다. 

단, 손가락이 휴대폰 화면에서 떨어지면 Game over 다.
 


Update : 2011. 9. 2

'Coding > Java 삽질기' 카테고리의 다른 글

[Android] Image match game ( V 0.2 )  (0) 2011.09.12
Java 실행 시간 측정 하기  (0) 2011.09.01
Java에서 객체의 초기화 순서  (0) 2011.08.24
Posted by chobocho
Coding/Java 삽질기2011. 9. 1. 01:39

public class Test {
    public static void main (String[] args) {
        long start_time = System.currentTimeMillis();
        
        //================================
        // Todo something
        
        // ===============================

        System.out.println ("Time : " + (System.currentTimeMillis() - start_time));
    }
}

'Coding > Java 삽질기' 카테고리의 다른 글

Press a ghost  (0) 2011.09.01
Java에서 객체의 초기화 순서  (0) 2011.08.24
[Android] Image match game  (0) 2011.06.04
Posted by chobocho
Coding/Java 삽질기2011. 8. 24. 23:58

자바는 Static block -> Instance block -> 생성자 순으로 초기화가 된다.

먼저 아래와 같은 코드를 실행해 보자.

public class TestClass {
    public static void main (String[] args) {
       System.out.println("---------------------------");
       
       Parent father = new Parent("father");
       
       System.out.println("---------------------------");
    }
}

class Parent {
    public String myName = "Parent";

    static {
        System.out.println ("This is first message of Parent class!");
    }

    public Parent() {
       System.out.println (myName + ": This is third message! I'm a default constructor of Parent class!");
    }

    public Parent(String name) {
        myName = name;
        System.out.println (myName + ": This is third message! I'm a constructor of Parent class!");
    }
    
    {
      System.out.println (myName + ": This is second message!");
    }
}


그럼 하기와 같은 결과를 얻을 수 있다.

---------------------------
This is first message of Parent class!
Parent: This is second message!
father: This is third message! I'm a constructor of Parent class!
---------------------------



 public class TestClass {

    public static void main (String[] args) {
       System.out.println("---------------------------");
       
       Parent father = new Parent("father");
       Parent mother = new Parent("mother");
       
       System.out.println("---------------------------");
    }
}

class Parent {
    public String myName = "Parent";

    static {
        System.out.println ("This is first message of Parent class!");
    }

    public Parent() {
       System.out.println (myName + ": This is third message! I'm a default constructor of Parent class!");
    }

    public Parent(String name) {
        myName = name;
        System.out.println (myName + ": This is third message! I'm a constructor of Parent class!");
    }
    
    {
      System.out.println (myName + ": This is second message!");
    }
}


 위 와 같이 한 줄을 추가하여 실행하면 아래와 같은 결과를 얻을 수 있다.

---------------------------
This is first message of Parent class!
Parent: This is second message!
father: This is third message! I'm a constructor of Parent class!
Parent: This is second message!
mother: This is third message! I'm a constructor of Parent class!
---------------------------


여기서 보면 static { }  으로 둘러 싸인 구문은 객체 생성시 최초 1회만 수행이 되고, 그 뒤에는 수행이 되지 않는 걸 알 수 있다. 그러나 { } 로 둘러싸인 instance block은 객체가 생성 될 때마다 실행 되며 생성자 보다 먼저 생성되는 걸 알 수 있다.

class Child extends Parent {
    public String myName = "Child";

    static {
        System.out.println ("This is first message of Child class!");
    }

    public Child(String name) {
        myName = name;
        System.out.println (myName + ": This is third message! I'm a constructor of Child class!");
    }
    
    {
      System.out.println (this.myName + ": This is second message of Child class!");
    }
  
}



위 와 같이 Parent class를 상속받는 Child 클래스를 만들고, 아래와 같이 객체를 생성해 보자

public class TestClass {
    public static void main (String[] args) {
       System.out.println("---------------------------");
       
         Child son     = new Child("son");
       
       System.out.println("---------------------------");
    }



그럼 하기와 같은 결과가 나온다.

---------------------------
This is first message of Parent class!
This is first message of Child class!
Parent: This is second message!
Parent: This is third message! I'm a default constructor of Parent class!
Child: This is second message of Child class!
son: This is third message! I'm a constructor of Child class!
---------------------------


위 결과를 보면 알 수 있듯이,
부모 클래스의 static block -> 자식 클래스의 static block -> 부모 클래스의 instance block
-> 부모 클래스의 생성자 -> 자식 클래스의 instance block -> 자식클래스의 생성자 순으로 실행 되는 것을 알 수 있다.

마지막으로 아래와 같이 실행을 하면,

public class TestClass {
    public static void main (String[] args) {
       System.out.println("---------------------------");
       
       Parent father = new Parent("father");
      Parent mother = new Parent("mother");
       Child son     = new Child("son");
       
       System.out.println("---------------------------");
    }
}



하기와 같이 실행 된다. 천천히 살펴보면 앞에서 설명한 내용에서 벗어나지 않는다.

---------------------------
This is first message of Parent class!
Parent: This is second message!
father: This is third message! I'm a constructor of Parent class!
Parent: This is second message!
mother: This is third message! I'm a constructor of Parent class!
This is first message of Child class!
Parent: This is second message!
Parent: This is third message! I'm a default constructor of Parent class!
Child: This is second message of Child class!
son: This is third message! I'm a constructor of Child class!
---------------------------





 

'Coding > Java 삽질기' 카테고리의 다른 글

Java 실행 시간 측정 하기  (0) 2011.09.01
[Android] Image match game  (0) 2011.06.04
Android Tetris  (0) 2011.02.02
Posted by chobocho
Coding/Java 삽질기2011. 6. 4. 19:56


즐거운 연휴~ 심심해서(?) 만들어 본 간단한 안드로이드용 퍼즐 게임



게임 방법

1. 빈 곳을 터치하면 상하좌우에서 동일한 이미지가 2개 있으면 삭제한다.
2. 빈 곳을 터치했으나 삭제할 수 있는 이미지가 없으면 타이머가 준다.
 
 
 

'Coding > Java 삽질기' 카테고리의 다른 글

Java에서 객체의 초기화 순서  (0) 2011.08.24
Android Tetris  (0) 2011.02.02
Bubble sort  (0) 2010.07.11
Posted by chobocho
Coding/Java 삽질기2011. 2. 2. 02:41


Galaxy Tab 전용으로 만든 테트리스.

아직 갈 길이 멀다.
 

'Coding > Java 삽질기' 카테고리의 다른 글

[Android] Image match game  (0) 2011.06.04
Bubble sort  (0) 2010.07.11
Selection sort  (0) 2010.07.11
Posted by chobocho