Ruang penulis
SEBUAH JURNAL TENTANG TEKNOLOGI

Belajar hal baru.
Tulis. Bagikan.

Ruang untuk merangkai pengetahuan, satu baris kode setiap hari.
Temukan tutorial, ide, dan catatan dari perjalanan belajar.

1914 catatan & terus bertumbuh
PILIHAN EDITOR
Java

Memahami Java Stream: olah koleksi dengan lebih ringkas

Pelajari alur filter, map, dan collect untuk mengolah data Java dengan kode yang mudah dibaca.

D Tim Diary Coding · 1 menit baca
UNTUK RASA INGIN TAHUMU

Catatan terbaru.

REFLECTION / CATATAN</>
Reflection12 Des 2010

How do I get the component type of array?

The Class.getComponentType() method call returns the Class representing the component type of array. If this class does not represent an array class this method returns null reference instead. package org.kodejava.lang.reflect; public class ComponentTypeDemo { public static void main(String[] args) { String[] words = {"and", "the"}; int[][] matrix = {{1, 1}, {2, 1}}; Double number = […]

Wayan · 1 menit baca
REFLECTION / CATATAN</>
Reflection12 Des 2010

How do I determine if a class object represents an array class?

For checking if a class object is representing an array class we can use the isArray() method call of the Class object. This method returns true if the checked object represents an array class and false otherwise. package org.kodejava.lang.reflect; public class IsArrayDemo { public static void main(String[] args) { int[][] matrix = {{1, 1}, {2, […]

Wayan · 1 menit baca
REFLECTION / CATATAN</>
Reflection11 Des 2010

How do I get direct superclass and interfaces of a class?

Java reflection also dealing with inheritance concepts. You can get the direct interfaces and direct super class of a class by using method getInterfaces() and getSuperclass() of java.lang.Class object. getInterfaces() will returns an array of Class objects that represent the direct super interfaces of the target Class object. getSuperclass() will returns the Class object representing […]

Wayan · 2 menit baca
REFLECTION / CATATAN</>
Reflection11 Des 2010

How do I check if a class represent an interface type?

You can use the isInterface() method call of the java.lang.Class to identify if a class objects represent an interface type. package org.kodejava.lang.reflect; import java.io.Serializable; public class IsInterfaceDemo { public static void main(String[] args) { IsInterfaceDemo.get(Serializable.class); IsInterfaceDemo.get(Long.class); } private static void get(Class<?> clazz) { if (clazz.isInterface()) { System.out.println(clazz.getName() + " is an interface type."); } else […]

Wayan · 1 menit baca
REFLECTION / CATATAN</>
Reflection11 Des 2010

How do I check if a class represent a primitive type?

Java uses class objects to represent all eight primitive types. A class object that represents a primitive type can be identified using the isPrimitive() method call. void is not a type in Java, but the isPrimitive() method returns true for void.class. package org.kodejava.lang.reflect; public class IsPrimitiveDemo { public static void main(String[] args) { IsPrimitiveDemo.get(int.class); IsPrimitiveDemo.get(String.class); […]

Wayan · 1 menit baca
REFLECTION / CATATAN</>
Reflection11 Des 2010

How do I get information regarding class name?

package org.kodejava.lang.reflect; import java.util.Date; public class ClassNameDemo { public static void main(String[] args) { Date date = new Date(); // Gets the Class of the date instance. Class<?> clazz = date.getClass(); // Gets the name of the class. String name = clazz.getName(); System.out.println("Class name : " + name); // Gets the canonical name of the […]

Wayan · 1 menit baca

Pengetahuan tumbuh ketika dibagikan.

Simpan rasa ingin tahu. Selalu ada hal baru untuk dipelajari.

Jelajahi catatan ↗
Putu Adi Guna Permana
TENTANG PENULIS

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Penulis dan pendiri Diary Coding — berbagi catatan, tutorial, dan pengalaman seputar pemrograman untuk siapa pun yang ingin terus belajar.