Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Primitive type Object reference
- From: boazbk@xxxxxxxxxxxxxx (Boaz Barak)
- Subject: Primitive type Object reference
- Date: Wed, 7 Oct 1998 02:14:00 +0200
From: Brian Smith <jlistbps@xxxxxxxxxxx>
> I read once that it is possible to "send" a call to a primitive type
> variable(like int j = 5) and obtain a reference to the Object that
> represents the primitive type variable in the VM. Does this sound familar
> to anyone? If yes, what do I need to do to get the Object reference?
I don't quite understand how can you be in a situation where you don't know
at compile time the exact type of the primitive and therefore know the type
for the correct wrapper (unless you are manipulating bytecode).
You can probably write an overloaded static function that will do this such
as:
Integer getWrapper(int i) { return new Integer(i); }
Long getWrapper(long l) { return new Long(l); }
...
Boaz Barak
boazbk@xxxxxxxxxxxxxx
(also: boazbk@xxxxxxxxxxxxxx)
---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- Prev by Date: Thread problem
- Previous by thread: Thread problem
- Index(es):