#can Class.forName("test.Something") be replaced with Something.class ??
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
wdym
Take "Class<T> clazz" as a parameter and convert to "clazz.getSimpleName()", then you can use it like that.
I'm assuming they want to call "ClassName.class" instead of always getting the name of a certain class by handWriting the longer bit
But their question is very vague and doesn't contain any specific code examples for what they want it for, so I don't really know what the answer they expect would be.
the handwriting the longer bit is useful only when you don't know at compile time the class will be there
or if you want to do some late loading bullshit
so you can use ClassName.class for sure
if i have:
Class oclass1 = Class.forName("java.awt.Desktop");
can i replace it with:
Class<Desktop> oclass1 = Desktop.class;
yes
thx