Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Tutorial: Introduction to Object-Oriented Programming

by jreades (Friar)
on Dec 10, 2002 at 21:59 UTC ( #218933=note: print w/replies, xml ) Need Help??


in reply to Re: Tutorial: Introduction to Object-Oriented Programming
in thread Tutorial: Introduction to Object-Oriented Programming

Java has both primitives and object-versions for each of the primitives. I think that the Java designers knew that they would have a mutiny if they forced everyone to write:

Integer i = new Integer(3);

So they gave you a short-hand way (that doesn't give you the object functionality) which is:

int i = 3;

However, you can always promote your primitives to objects, and the primitives very limited (you can't even do string concatenation without using a StringBuffer object). Actually, to be more specific (since gjb rightly called me on this):

  • When you call the overloaded '+' on two String objects in Java, what is actually returned is an entirely new String that is the result of concatenating the two previous Strings (this is also the case when using '+=' -- you actually get back a new String object, not the old one with some new characters appended to it. Strings are essentially immutable in Java.)
  • This is why you would want to switch to a StringBuffer object when doing a lot of appending in Java, because that doesn't create a lot of new String objects unecessarily.

Anyway, my point was really that Java likes to see the entire world as objects, even the things that we Perl users normally see as primitives, and that to really start to actually do anything in Java you're going to have to get used to objects pretty quickly.

However, your point is well-taken and I'm going to be making some edits to my post to take in your (and others') feedback.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://218933]
help
Chatterbox?
[marto]: After Sunday I don't think I'll go see them again :)
[LanX]: Corion: come on, people are people! ;)
[Corion]: Naah, I think it's still an OK show so far. Their new songs aren't exactly great, but I'm not going there for new material anyway ;)
[marto]: I got the feeling from the last show that for big sections of it, they were not really into what they were doing
[Corion]: LanX: Sure, they can bask in my Halo
[marto]: more so than the previous show I saw
[Corion]: marto: Well, I think they go a tour every two years and I think it's hard to even get a connection with the crowd at a 20k people concert... But maybe after this time I'll stop too ;)
[Corion]: I still have to see the Pet Shop Boys live before they stop touring at all
[marto]: yeah, I think that as a group creatively they're done. I can understand how it'd be hard to stop the process, album/tour, album/tour, if that's pretty much all you've ever done :)
[marto]: Corion yes I saw them Pandemonium_Tour

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2017-03-24 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (301 votes). Check out past polls.