When you write .class
after a class name, it references the class literal – java.lang.Class
object that represents information about given class.
For example, if your class is Print
, then Print.class
is an object that represents the class Print
on runtime. It is the same object that is returned by the getClass()
method of any (direct) instance of Print
.
Print myPrint = new Print(); System.out.println(Print.class.getName()); System.out.println(myPrint.getClass().getName());
Related Posts:
- Class Declarations for temperature program in Java
- What does “Could not find or load main class” mean?
- What does “Could not find or load main class” mean?
- How do I resolve ClassNotFoundException?
- Java: Multiple class declarations in one file
- what is the difference between `public class` and just `class`?
- method in class cannot be applied to given types
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- Usage of @see in JavaDoc?
- How do you make a deep copy of an object?
- java, get set methods
- How to identify object types in java
- method in class cannot be applied to given types
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- implicit super constructor Person() is undefined. Must explicitly invoke another constructor?
- What is the difference between Integer and int in Java?
- Why nextLine() and not nextString() ?
- Java Class File Editor
- Import a custom class in Java
- Java The method is undefined for this type
- java sort using anonymous class
- When is the finalize() method called in Java?
- Import a custom class in Java
- Error: Generic Array Creation
- Error: Main method not found in class Calculate, please define the main method as: public static void main(String[] args) [duplicate]
- Java – get the current class name?
- Call a Class From another class
- How to return a boolean method in java?
- .class vs .java
- What is a class constant?
- Why do some classes require main methods and others do not?
- Node cannot be resolved to a type
- fixing errors on a program to call methods in java
- incompatible types: void cannot be converted to int [duplicate]
- Python-like list comprehension in Java
- Java methods getting euclidean distance
- How can i fix this equals on primitive type(int)
- Return outside method error
- Could not find or load main class with a Jar File
- How can I design a class named allergy?
- What does Java option -Xmx stand for? [duplicate]
- Finding white rectangle in an image
- How to use the toString method in Java?
- Unable to find valid certification path to requested target – error even after cert imported
- Java : Comparable vs Comparator [duplicate]
- Convert int to char in java
- Change date format in a Java string
- Converting String to “Character” array in Java
- Java – What does “\n” mean? [duplicate]
- must declare a named package eclipse because this compilation unit is associated to the named module
- How can I prevent java.lang.NumberFormatException: For input string: “N/A”?
- Compiled vs. Interpreted Languages
- How to round up to the next integer?
- Spring @PropertySources value not overriding
- Array ArrayList python equivalent
- Java ArrayList copy
- How do I apply the for-each loop to every character in a String?
- Session TimeOut in web.xml
- Java – removing first character of a string
- How to send a Map in JSON
- Gradle does not find tools.jar
- How can I list the available Cipher algorithms?
- ADK vs JDK vs SDK difference?
- round up to 2 decimal places in java?
- com.sun.jdi.InvocationException occurred invoking method
- How can I check whether an array is null / empty?
- How to solve javax.net.ssl.SSLHandshakeException Error?
- org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘demoRestController’
- What causes java.lang.IncompatibleClassChangeError?
- Add an object to an Array of a custom class
- IO Error: The Network Adapter could not establish the connection
- How to create a directory in Java?
- Converting from Integer, to BigInteger
- Get a resource using getResource()
- Java comparing generic types
- Simplest way to read JSON from a URL in Java
- An established connection was aborted by the software in your host machine tomcat jackson
- Generate a random double in a range
- How to open a new tab using Selenium WebDriver in Java?
- Selenium Webdriver: Element Not Visible Exception
- Whitespace Matching Regex – Java
- Unreachable code in eclipse
- “Field can be converted to a local variable” message appearing when setting Android ActionBar colour
- Convert an integer to an array of digits
- Android Emulator: Unfortunately App has stopped
- Can we execute a java program without a main() method? [duplicate]
- How to really read text file from classpath in Java
- Java command not found on Linux
- Selenium using Java – The path to the driver executable must be set by the webdriver.gecko.driver system property
- How to break out or exit a method in Java?
- Java Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
- Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/JDBC_DBO]]
- How to get Java to wait for user Input
- Java using enum with switch statement
- Removing double quotes from a string in Java
- What is inverse function to XOR?
- Java Swing revalidate() vs repaint()
- Append a single character to a string or char array in java?
- for each loop in groovy
- Details of difference between @see and @inheritDoc