The Artima Developer Community
Sponsored Link

Java Answers Forum
For the sake of interest. (Wrapper vs. primitive)

5 replies on 1 page. Most recent reply: Aug 1, 2005 2:27 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 5 replies on 1 page
Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

For the sake of interest. (Wrapper vs. primitive) Posted: Jul 27, 2005 7:03 AM
Reply to this message Reply
Advertisement
Why is it that in Eclipse (haven't tried this
manually yet) if I have an Object that
takes in Boolean the wrapper *Object* for the
primitive boolean as a parameter, it doesn't
complain when I pass in its primitive.

E.g:


class A{
public A(Boolean t){
// do something
}
}

Making the call.



Why does this the following call not result in
a compile time error?

// Passes compilation
A my_obj = new A(false);


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: For the sake of interest. (Wrapper vs. primitive) Posted: Jul 27, 2005 8:10 AM
Reply to this message Reply
Because you're using J2 v1.5

http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#boxing

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: For the sake of interest. (Wrapper vs. primitive) Posted: Jul 27, 2005 8:17 AM
Reply to this message Reply
Makes sense.

Tx

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: For the sake of interest. (Wrapper vs. primitive) Posted: Jul 27, 2005 10:59 PM
Reply to this message Reply
I prefer the old style wich makes me plan/think a bit more.

Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: For the sake of interest. (Wrapper vs. primitive) Posted: Jul 29, 2005 11:08 PM
Reply to this message Reply
Hmm... Does the old way help you think at a higher level about your design, or just more about little details?

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: For the sake of interest. (Wrapper vs. primitive) Posted: Aug 1, 2005 2:27 AM
Reply to this message Reply
Little details.

I distinguish between design and implementation.

In my opinion the implementation should not be too easy. Knowing every detail of big parts of the code helps me if I have to do some changes.

Flat View: This topic has 5 replies on 1 page
Topic: Varying Fonts on a Panel Previous Topic   Next Topic Topic: to build GUI like BlueJ

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use