• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

.class what does it do

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am not a spy. Definitely. Definitely not a spy. Not me. No way. But this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic