I have a class A. I have a reference ref of class A pointing to an object of type x.
What kind of object makes ref.getClass() print A$1 ? And what does $ signify?
I have a class A. I have a reference ref of class A pointing
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The $ signifies an inner class. In this case:
The Runnable inside the constructor will result in a class file A$1.class and the Inner class will create a file called A$Inner.class.
Anonymous inner classes are sequentially numbered from 1 as they are encountered (although I’m not sure this behaviour is guaranteed or not). Named inner classes append their name after the $.