[Java] Let me ask you about grammar

Asked 2 years ago, Updated 2 years ago, 106 views

private static Logger logger = Logger.getLogger(CopyUtil.class); I saw the chords like this I'm inquiring because there's something I don't understand grammatically.

"CopyUtil.class." Like this. xxx.I wonder if it is right to pass the class file as a factor to throw the class as a factor, or how to understand it grammatically.

I'd appreciate it if you could explain it grammatically.

java syntax

2022-09-22 20:55

1 Answers

Provides Java's Reflection API. Think of Reflection as providing a way to look up your own code. The programming API allows you to access both what methods are in the class and what factors the function is in.

So in Java, Class is one type.

CopyUtil.class becomes an instance of the class.

an adverb of

When writing Logger names in Java, it is customary to use the class name that corresponds to the name of the class, so it is recommended to use the class name (including the package name) as the Logger name.

If you cross XXX.class from the logger factory pattern above, you will automatically extract the logger name using the Reflection API of the class internally.


2022-09-22 20:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.