The class type dynamically assigned to the variableHow does array class work in Java?Java inner class and static nested classFastest way to determine if an integer's square root is an integerJava Class that implements Map and keeps insertion order?Where does the @Transactional annotation belong?How to get a class instance of generics type TDifference between <context:annotation-config> vs <context:component-scan>Error: Could not find or load main classStatic Classes In JavaWhy don't Java's +=, -=, *=, /= compound assignment operators require casting?Is not an enclosing class Java
How to compare two different formulations of a problem?
Why aren't RCS openings an issue for spacecraft heat shields?
In the MCU, why does Mjölnir retain its enchantments after Ragnarok?
Most practical knots for hitching a line to an object while keeping the bitter end as tight as possible, without sag?
What does it mean to have a subnet mask /32?
Are illustrations in novels frowned upon?
If the first law of thermodynamics ensures conservation of energy, why does it allow systems to lose energy?
Shouldn't the "credit score" prevent Americans from going deeper and deeper into personal debt?
Can pay be witheld for hours cleaning up after closing time?
What is the hex versus octal timeline?
Is it appropriate for a prospective landlord to ask me for my credit report?
If all stars rotate, why was there a theory developed, that requires non-rotating stars?
Is it possible to create a golf ball sized star?
Efficiently pathfinding many flocking enemies around obstacles
Co-author responds to email by mistake cc'ing the EiC
Can I switch to third-person while not in 'town' in Destiny 2?
Why is observed clock rate < 3MHz on Arduino Uno?
The teacher logged me in as administrator for doing a short task, is the whole system now compromised?
Is it safe to remove the bottom chords of a series of garage roof trusses?
If I have a 16.67% fail rate (N=24) & I do another 24 tests, what is the likelihood that I get 0 fails by chance?
Science fiction short story where aliens contact a drunk about Earth's impending destruction
Why is 日本 read as "nihon" but not "nitsuhon"?
Verb form to finish someone else's sentence?
Avoiding racist tropes in fantasy
The class type dynamically assigned to the variable
How does array class work in Java?Java inner class and static nested classFastest way to determine if an integer's square root is an integerJava Class that implements Map and keeps insertion order?Where does the @Transactional annotation belong?How to get a class instance of generics type TDifference between <context:annotation-config> vs <context:component-scan>Error: Could not find or load main classStatic Classes In JavaWhy don't Java's +=, -=, *=, /= compound assignment operators require casting?Is not an enclosing class Java
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm wrapping an Axis web service in a Springboot microservice and stumbled on some code that does not make sense.
Class cls = AmountInfo[].class;
What class is returned above ?
java compilation
add a comment |
I'm wrapping an Axis web service in a Springboot microservice and stumbled on some code that does not make sense.
Class cls = AmountInfo[].class;
What class is returned above ?
java compilation
Possible duplicate of How does array class work in Java?
– vincrichaud
Mar 27 at 16:08
That's what would be called theAmountInfo
array class, and that's different from the class ofAmountInfo
– ernest_k
Mar 27 at 16:09
By the wayint.class
is an other exotic class.
– Joop Eggen
Mar 27 at 16:10
"What class is returned above" - why did not you call "System.out.println(cls.getName())"?
– Alexei Kaigorodov
Mar 27 at 17:18
add a comment |
I'm wrapping an Axis web service in a Springboot microservice and stumbled on some code that does not make sense.
Class cls = AmountInfo[].class;
What class is returned above ?
java compilation
I'm wrapping an Axis web service in a Springboot microservice and stumbled on some code that does not make sense.
Class cls = AmountInfo[].class;
What class is returned above ?
java compilation
java compilation
edited Mar 27 at 16:07
ernest_k
27k4 gold badges32 silver badges55 bronze badges
27k4 gold badges32 silver badges55 bronze badges
asked Mar 27 at 16:06
VankuisherVankuisher
966 bronze badges
966 bronze badges
Possible duplicate of How does array class work in Java?
– vincrichaud
Mar 27 at 16:08
That's what would be called theAmountInfo
array class, and that's different from the class ofAmountInfo
– ernest_k
Mar 27 at 16:09
By the wayint.class
is an other exotic class.
– Joop Eggen
Mar 27 at 16:10
"What class is returned above" - why did not you call "System.out.println(cls.getName())"?
– Alexei Kaigorodov
Mar 27 at 17:18
add a comment |
Possible duplicate of How does array class work in Java?
– vincrichaud
Mar 27 at 16:08
That's what would be called theAmountInfo
array class, and that's different from the class ofAmountInfo
– ernest_k
Mar 27 at 16:09
By the wayint.class
is an other exotic class.
– Joop Eggen
Mar 27 at 16:10
"What class is returned above" - why did not you call "System.out.println(cls.getName())"?
– Alexei Kaigorodov
Mar 27 at 17:18
Possible duplicate of How does array class work in Java?
– vincrichaud
Mar 27 at 16:08
Possible duplicate of How does array class work in Java?
– vincrichaud
Mar 27 at 16:08
That's what would be called the
AmountInfo
array class, and that's different from the class of AmountInfo
– ernest_k
Mar 27 at 16:09
That's what would be called the
AmountInfo
array class, and that's different from the class of AmountInfo
– ernest_k
Mar 27 at 16:09
By the way
int.class
is an other exotic class.– Joop Eggen
Mar 27 at 16:10
By the way
int.class
is an other exotic class.– Joop Eggen
Mar 27 at 16:10
"What class is returned above" - why did not you call "System.out.println(cls.getName())"?
– Alexei Kaigorodov
Mar 27 at 17:18
"What class is returned above" - why did not you call "System.out.println(cls.getName())"?
– Alexei Kaigorodov
Mar 27 at 17:18
add a comment |
1 Answer
1
active
oldest
votes
Here's what the docs of java.lang.Class
have to say about this:
Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions.
Just as the a Class
object for the type AmountInfo
, there is a Class
for the array 1D array type AmountInfo[]
, just as there is also a type for the 2D array type AmountInfo[][]
, etc.
A Class
of an array type returns true
when isArray()
is invoked on it. AmountInfo[].class
is equivalent to AmountInfo.class.arrayType()
. And you can use it with the reflection API the same way you can use a normal class (example below):
//Creating a 1D array of AmountInfo type
jshell> Array.newInstance(AmountInfo.class, 2)
$65 ==> AmountInfo[2] null, null
// Creating a 2D array of AmountInfo type
jshell> Array.newInstance(AmountInfo[].class, 2)
$66 ==> AmountInfo[2][] null, null
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381735%2fthe-class-type-dynamically-assigned-to-the-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here's what the docs of java.lang.Class
have to say about this:
Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions.
Just as the a Class
object for the type AmountInfo
, there is a Class
for the array 1D array type AmountInfo[]
, just as there is also a type for the 2D array type AmountInfo[][]
, etc.
A Class
of an array type returns true
when isArray()
is invoked on it. AmountInfo[].class
is equivalent to AmountInfo.class.arrayType()
. And you can use it with the reflection API the same way you can use a normal class (example below):
//Creating a 1D array of AmountInfo type
jshell> Array.newInstance(AmountInfo.class, 2)
$65 ==> AmountInfo[2] null, null
// Creating a 2D array of AmountInfo type
jshell> Array.newInstance(AmountInfo[].class, 2)
$66 ==> AmountInfo[2][] null, null
add a comment |
Here's what the docs of java.lang.Class
have to say about this:
Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions.
Just as the a Class
object for the type AmountInfo
, there is a Class
for the array 1D array type AmountInfo[]
, just as there is also a type for the 2D array type AmountInfo[][]
, etc.
A Class
of an array type returns true
when isArray()
is invoked on it. AmountInfo[].class
is equivalent to AmountInfo.class.arrayType()
. And you can use it with the reflection API the same way you can use a normal class (example below):
//Creating a 1D array of AmountInfo type
jshell> Array.newInstance(AmountInfo.class, 2)
$65 ==> AmountInfo[2] null, null
// Creating a 2D array of AmountInfo type
jshell> Array.newInstance(AmountInfo[].class, 2)
$66 ==> AmountInfo[2][] null, null
add a comment |
Here's what the docs of java.lang.Class
have to say about this:
Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions.
Just as the a Class
object for the type AmountInfo
, there is a Class
for the array 1D array type AmountInfo[]
, just as there is also a type for the 2D array type AmountInfo[][]
, etc.
A Class
of an array type returns true
when isArray()
is invoked on it. AmountInfo[].class
is equivalent to AmountInfo.class.arrayType()
. And you can use it with the reflection API the same way you can use a normal class (example below):
//Creating a 1D array of AmountInfo type
jshell> Array.newInstance(AmountInfo.class, 2)
$65 ==> AmountInfo[2] null, null
// Creating a 2D array of AmountInfo type
jshell> Array.newInstance(AmountInfo[].class, 2)
$66 ==> AmountInfo[2][] null, null
Here's what the docs of java.lang.Class
have to say about this:
Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions.
Just as the a Class
object for the type AmountInfo
, there is a Class
for the array 1D array type AmountInfo[]
, just as there is also a type for the 2D array type AmountInfo[][]
, etc.
A Class
of an array type returns true
when isArray()
is invoked on it. AmountInfo[].class
is equivalent to AmountInfo.class.arrayType()
. And you can use it with the reflection API the same way you can use a normal class (example below):
//Creating a 1D array of AmountInfo type
jshell> Array.newInstance(AmountInfo.class, 2)
$65 ==> AmountInfo[2] null, null
// Creating a 2D array of AmountInfo type
jshell> Array.newInstance(AmountInfo[].class, 2)
$66 ==> AmountInfo[2][] null, null
answered Mar 27 at 16:31
ernest_kernest_k
27k4 gold badges32 silver badges55 bronze badges
27k4 gold badges32 silver badges55 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55381735%2fthe-class-type-dynamically-assigned-to-the-variable%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Possible duplicate of How does array class work in Java?
– vincrichaud
Mar 27 at 16:08
That's what would be called the
AmountInfo
array class, and that's different from the class ofAmountInfo
– ernest_k
Mar 27 at 16:09
By the way
int.class
is an other exotic class.– Joop Eggen
Mar 27 at 16:10
"What class is returned above" - why did not you call "System.out.println(cls.getName())"?
– Alexei Kaigorodov
Mar 27 at 17:18