• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

.class what does it do

 
Praveen Seluka
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I came across this code...

LoggerFactory.getLogger(DispatcherThread.class);

Actually this method requies a String as an argument so what is this DispatcherThread.class doing there as a parameter.

I have never come across this.Any help

Thanks
Praveen SP
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Praveen Seluka:

I came across this code...

LoggerFactory.getLogger(DispatcherThread.class);

Actually this method requies a String as an argument so what is this DispatcherThread.class doing there as a parameter.


Assuming that code compiles, that's proof that there also is a getLogger method that accepts a Class object as an argument. Either the method is overloaded, or the LoggerFactory is a different class than you thought.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Every object in Java is an instance of a class, as you know. There's also a class named "Class" in the standard library, that you can use to find out information about the class of an object.

The ".class" notation is a way to get the Class object of a Java class. For example:

 
Praveen Seluka
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi jesper

Thanks for your information.
so in my above code
LoggerFactory.getLogger(DispatcherThread.class);

The dispatcher.class is a class object and it gets the String there from the toString method.right? Sorry that am not clear in my language

Praveen SP
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Praveen Seluka:
The dispatcher.class is a class object and it gets the String there from the toString method.right?


No. Read Ilja's post again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic