Autoboxing confusion!!!

S

Subho

Hi,
1. Class Example {
2. public static void main(String args[]) {
3. Short s = 15;
4. Boolean b;
5. b = (s instanceof Short);
6. b = (s instanceof Number);
7. }
8. }

In the above given line of code can anybody tell where(line
number) autoboxing is happening and how???

Thanks in advance,
Subho
 
D

Donkey Hot

Hi,
1. Class Example {
2. public static void main(String args[]) {
3. Short s = 15;
4. Boolean b;
5. b = (s instanceof Short);
6. b = (s instanceof Number);
7. }
8. }

In the above given line of code can anybody tell where(line
number) autoboxing is happening and how???

Thanks in advance,
Subho

On lines 3, 5 and 6.

3. Short s = new Short(15);
5. b = new Boolean(s instanceof Short);
6. b = new Boolean(s instanceof Number);
 
L

Lew

Donkey said:
Hi,
1. Class Example {
2. public static void main(String args[]) {
3. Short s = 15;
4. Boolean b;
5. b = (s instanceof Short);
6. b = (s instanceof Number);
7. }
8. }

In the above given line of code can anybody tell where(line
number) autoboxing is happening and how???

Thanks in advance,
Subho

On lines 3, 5 and 6.

3. Short s = new Short(15);
5. b = new Boolean(s instanceof Short);
6. b = new Boolean(s instanceof Number);

OP, if you are having trouble with the "how" part, seek advice from your
professor or a classmate.
 

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
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top