본문 바로가기
[Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection [Kotlin Tutorial] Annotation 과 Reflection #1 - Chap 10. Annotations and reflection 참조 : Kotlin in action 10.1. Declaring and applying annotations. 10.1.1. Applying annotations -Annotation 사용법은 Java 와 동일하다. @ 를 prefix 로 하고 annotation name 을 써주면 된다. -@Deprecated 의 경우 Kotlin 은 Java 의 것에서 향상되었다.replaceWith parameter 가 추가되어, 새로운 version 의 API 에 연결될 수 있다.@Deprecated(“Use removeAt(index) instead.”, Rep.. 2017. 9. 7.
[Kotlin Tutorial] Kotlin 의 Type system #2 [Kotlin Tutorial] Kotlin 의 Type system #2 참조 : Kotlin in action 6.2. Primitive and other basic types 6.2.1. Primitive types: Int, Boolean, and more -Kotlin 은 primitive type 과 wrapper type 을 구분하지 않는다. -그렇다면 Int 가 object 라면 Kotlin 은 모든 primitive type 을 실제로 object 로 만드는가?당연히 그렇게 안 했다.compiler 가 대부분의 Int type 을 Java 의 primitive type 으로 변형시킨다.generic, collection 등은 원래 Java 의 Integer 형태만 담을 수 있으므로 이 경.. 2017. 8. 22.
[Effective Java] Comparable 인터페이스의 구현을 고려하자. [Effective Java] Comparable 인터페이스의 구현을 고려하자. - compareTo 메소드는 Comparable 인터페이스에 존재하는 메소드이다. compareTo 메소드는 equals 메소드와 유사한 특성을 갖는다. 차이점은 두 객체가 동일한지 비교에 덧붙여 순서까지 비교할 수 있으며, 제네릭 타입을 지원한다. - Comparable interface 를 구현하면, Arrays.sort 와 같은 메소드를 손쉽게 쓸 수 있고, TreeSet 과 같은 크기 비교를 사용하는 Collection 들에서도 손쉽게 사용할 수 있다. - 자바 라이브러리의 모든 값 클래스들은 Comparable 인터페이스를 구현한다. - 알파벳 순, 숫자 순, 날짜 순과 같은 자연율을 갖는 값 클래스를 작성한다면 .. 2016. 10. 14.
[Java] Reflection Tutorial - Array Java, Reflection Tutorial - Array java.lang.reflect.Array array 에 대한 reflection 은 java.lang.reflect.Array 를 통해서 이루어진다. array 의 util 함수들을 가지고 있는 java.util.Arrays 와 착각하지 말자. Creating Arrays int[] intArray = (int[]) Array.newInstance( int.class, 3 ); Accessing Arrays int[] intArray = (int[]) Array.newInstance( int.class, 3 ); Array.set( intArray, 0, 123 );int a = Array.get( intArray, 0 ); Obtaining.. 2013. 12. 30.
반응형