How do I know if an array of Bytes is as large as 2MB

  • Thread starter Iratxe Monasterio
  • Start date
I

Iratxe Monasterio

Hi !!!!!!
How do I know if an array of Bytes is as large as 2MB, for example????
If anyone can help me ???
Thank you,

Iratxe
 
D

Darryl L. Pierce

Iratxe said:
Hi !!!!!!
How do I know if an array of Bytes is as large as 2MB, for example????
If anyone can help me ???

byte[] array;

if(array.length == (2 * 1024 * 1024)) ...
 
Z

zebulon

And is there a way to know the size taken in memory by any class instance ?

Darryl L. Pierce said:
Iratxe said:
Hi !!!!!!
How do I know if an array of Bytes is as large as 2MB, for example????
If anyone can help me ???

byte[] array;

if(array.length == (2 * 1024 * 1024)) ...
 
T

Thomas Weidenfeller

Thomas said:
Promise of "sizeof()" ...

Instrumentation is an interface, I had no luck locating a class that
implements it. On their ToDo list?

I don't think so. From the API documentation:

<quote>
The only way to access an instance of the Instrumentation interface is
to use the -javaagent command line switch; this will cause an
Instrumentation instance to be passed to the premain method. Once an
agent acquires the Instrumentation instance, the agent may call methods
on the instance at any time.
</quote>

In other words, no sizeof().

/Thomas
 
J

Joona I Palaste

Darryl L. Pierce said:
No. You would get an instance of a class the implements the interface at
runtime. Why do you think you need a concrete class listed in the APIs?

Because everyone knows there can't be instances of interfaces! Silly
Darryl!
Oh, wait, hang on...

--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The day Microsoft makes something that doesn't suck is probably the day they
start making vacuum cleaners."
- Ernst Jan Plugge
 
D

Darryl L. Pierce

Joona said:
Because everyone knows there can't be instances of interfaces! Silly
Darryl!
Oh, wait, hang on...

Uh huh. Here, have another cuppa. Remember, *never* reply before your first
cuppa in the morning... :)
 
D

Darryl L. Pierce

Thomas said:
Would I not need a factory class or method? - Aah, it's me being a bit
dense.

There will most likely be such a method provided to return to you a
singleton instance of a class that implements the interface. Since the
information is very platform specific, I'm sure that, like Toolkit, that's
the way it's going to go.
To my defence, this is the first I hear of a premain() method.

That's surely a part of the JVM itself and a reference to its C
implementation code.
 
T

Thomas Schodt

Darryl said:
That's surely a part of the JVM itself and a reference to its C
implementation code.

When I Google for it, they all look like

public static void premain(
String options, java.lang.instrument.Instrumentation foo
) {
// body
}

so I expect it's similar to main().
 
D

Darryl L. Pierce

Thomas said:
When I Google for it, they all look like

public static void premain(
String options, java.lang.instrument.Instrumentation foo
) {
// body
}

so I expect it's similar to main().

Hmmmm. I just assumed for some reason that it was a reference to
implementation. Apparently that was quite wrong of me to assume so. I've
not been tracking the new features with 1.5 but I'm guessing I'd better
check out the new specification and see what's up.

Does anybody know if there's a beta release for Linux as well?
 
C

Christophe Vanfleteren

Darryl said:
Hmmmm. I just assumed for some reason that it was a reference to
implementation. Apparently that was quite wrong of me to assume so. I've
not been tracking the new features with 1.5 but I'm guessing I'd better
check out the new specification and see what's up.

Does anybody know if there's a beta release for Linux as well?

Yes there is:
http://java.sun.com/j2se/1.5.0/download.jsp
 
J

Joona I Palaste

Uh huh. Here, have another cuppa. Remember, *never* reply before your first
cuppa in the morning... :)

My message was intended to parody a common newbie problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top