SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

REFLECTION / NOTES</>↗
Reflection11 Dec 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 min read
REFLECTION / NOTES</>↗
Reflection11 Dec 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 min read
REFLECTION / NOTES</>↗
Reflection11 Dec 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 min read
REFLECTION / NOTES</>↗
Reflection11 Dec 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 min read
SWING / NOTES</>↗
Swing12 Nov 2010

How do I select all text in JTextArea?

Selecting all text in the JTextArea component can be done by using the selectAll() method. In the example below we use a button action to do the selection. After select the text we transfer focus back to the JTextArea so that the highlighted text is shown. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaSelectAll […]

Wayan · 2 min read
SWING / NOTES</>↗
Swing12 Nov 2010

How do I append text to JTextArea?

To append text to the end of the JTextArea document we can use the append(String str) method. This method does nothing if the document is null or the string is null or empty. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaAppendText extends JPanel { public TextAreaAppendText() { initializeUI(); } public static void showFrame() { […]

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

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

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.