Forums Register Login

java.util.Arrays - why return static variables?

+Pie Number of slices to send: Send
All the methods in java.util.Arrays return static variables.

Why is it necessary to say return a static String from the toString(int[] a) method?

all clues are greatly appreciated!
[ February 18, 2008: Message edited by: Chris Jones ]
+Pie Number of slices to send: Send
Not in the JVM I am using at the moment (Sun's). There aren't even any static variables in the class that I can see. Why do you say that?
+Pie Number of slices to send: Send
 

Why is it necessary to say return a static String from the toString(int[] a) method?




The "static" in the definition is referring to the fact that the toString() method is static. It is not returning a "static String"...

Henry
+Pie Number of slices to send: Send
yes, sorry. I misread the java API docs. The column that holds the return type also holds the static modifier.

It is obviously the method that is static and not the return value. I got confused. But thanks for taking the time/sorry for wasting it.

/Chris
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1282 times.
Similar Threads
EJB static variables
static import
Interface methods must not be static.
"Static reference to non-static method"
ArrayList question
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:00:55.