Have a question about programming in Java...

Discussion in 'Mac Programming' started by mousouchop, Aug 9, 2011.

  1. mousouchop macrumors 6502a

    mousouchop

    Joined:
    Oct 22, 2008
    Location:
    New York
    #1
    Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_10 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8E600 Safari/6533.18.5)

    Hey guys, have just a couple general questions about the Java language and thought I would post them here, seeing as I have been reading Macrumors for years. If I can't get the answers here, I guess I'll go to a Java forum full of strangers...

    Anyways, just got a job as a programmer and will be programming
    in Java. While it's an entry-level position, and they have stated they intend to train me, I'd like to go in not being totally clueless.

    I ordered a book on Java only to realize it was published in 2005 and is about Java 5... the current version is Java 6. I'm wondering if I read through this book and learn 5, is 6 similar enough that my time and money will not have been wasted? Or should I find a book specfically on 6?

    Just throwing this in, I have 1.5 years experience in PHP database programming, so I won't be completely clueless on programming in general. I am just looking to get some of the syntax under my belt.
     
  2. JLatte macrumors 6502

    Joined:
    Dec 2, 2005
    Location:
    San Diego
    #2
    http://www.amazon.com/exec/obidos/ASIN/0132821540/deitelassociatin
    I find a lot of Deitel & Deitel books to be very good. This is a relatively new book from them, but based off the outside reviews as well as the 2 on Amazon it seems to be up your alley. The guy that gave it 2 stars on Amazon was because he was already in a C# .net environment so he didn't find it particularly useful until later chapters. Since you do PHP and not a .net environment, it sounds like it will be pretty applicable since you have programming knowledge.

    As for a book specifically on 6, I can't honestly say. Good luck!
     
  3. yg17 macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #3
    The differences between the versions are fairly minor, you'll be OK. Syntax doesn't change between versions, they just add new features. The changes in Java 6 were mostly behind the scenes enhancements with the compiler and JVM.

    I'm a Java developer and we recently migrated our huge enterprise application from Java 4 to Java 6 and didn't really have to make any changes to the code. The biggest advantage was being able to use stuff Java 5 added like generics and enums, but your Java 5 book should cover those.

    So you'll be fine with the Java 5 book - it will teach you the fundamentals like syntax and object oriented programming which haven't changed.
     
  4. mousouchop thread starter macrumors 6502a

    mousouchop

    Joined:
    Oct 22, 2008
    Location:
    New York
    #4
    Thanks so much! This is exactly what I wanted to hear. I assumed that syntax would be nearly identical, just wasn't sure if the features added in 6 were "behind the scenes" as you said, or stuff that would drastically change the way one would program in Java. Guess I'd better start reading! :p
     
  5. yg17 macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #5
    The fact you know PHP should help you quite a bit. There are a lot of differences that will take some getting used to - Java is object oriented and variables are typed (int, boolean, String, etc) unlike PHP. Java doesn't have associative arrays, but HashMaps are very similar to PHP's associative arrays. And variables in Java do not begin with a $ (the one thing that always gets me at first when my mind has to rapidly switch between Java and PHP), but syntax like loops, if/else statements, etc, is almost identical.
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Thread moved to Mac Programming so more interested parties can participate.

    B
     
  7. mousouchop thread starter macrumors 6502a

    mousouchop

    Joined:
    Oct 22, 2008
    Location:
    New York
    #7
    Thanks. I debated putting it here but wasn't sure if it was 100% relevant.

    Anyways, another question!

    I had been working out of another book before this one arrived that had me doing tutorials that outputted to web pages (.jsp). This new book has me doing tutorials that print to the terminal. The syntax seems to be a lot like PHP, so I am pretty comfortable with it thus far, but I can't help but feel the first book was slightly more relevant... I believe I will largely be making web apps when I start. Will this new book still help with that? I can only imagine there is something like the "echo" statement in PHP that would allow me to print to HTML, instead of using this System.out.print() to the terminal.

    I am sure I just haven't read in far enough, and am merely being impatient... but I am just nervous and wondering if I should go back to the other book.
     
  8. yg17 macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #8
    Web is really where PHP and Java differ.

    Having Java code in your JSP files is generally bad practice. Ideally, whoever you're working for will be using something like Struts, where your Java classes do all of the work, and then hand off control to a JSP that displays the page. Information is usually passed between the Java class and JSP with Java Beans, and the JSP accesses the bean to pull the info it needs to display on the page.

    I would say get comfortable with the Java basics first. And then find out if you'll even be using Struts (or another model-view-controller framework) at work before you dive into it. Struts is massive, I work with it nearly every day at work and I've barely scratched the surface.

    And if you're being hired at entry level, I would stick to the basics rather than specific Java technologies since you don't know what you'll be using at work. They should train you for the more advanced stuff that you'll need for your job. Definitely make sure you have the fundamentals down first, especially working with objects and inheritance. Those are something not often used in PHP that are the very foundations of Java.
     
  9. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #9
    More relevant here than anywhere else on MR.

    Heck we've even had recent threads on Pascal and FORTRAN, so Java is not much of a stretch at all. :p

    B
     
  10. kurayama macrumors newbie

    Joined:
    Jul 2, 2011
    #10
    Java 5 and 6 is almost the same, just some additions.
    Older versions are not recommended as many things are different.
    API, Collections without type checking, etc..
     
  11. yg17 macrumors G5

    yg17

    Joined:
    Aug 1, 2004
    Location:
    St. Louis, MO
    #11

    Heh, tell me about it. We upgraded from Java 4 to Java 6 and went from like 100 build warnings in 4 to 20,000 in 6 because none of our collections (and we use HashMaps extensively) weren't typed. Slowly but surely we're bringing that number down, as we modify a piece of code, we add the type parameters. But in most cases we type them to <String, Object>. String is good for the key, but typing the value to Object sorta defeats the purpose. But it shuts the compiler up ;)
     
  12. pilotError macrumors 68020

    pilotError

    Joined:
    Apr 12, 2006
    Location:
    Long Island
    #12
    You should look at the new "for" syntax for iterators. It makes code much cleaner to look at. It looks a little strange at first until you understand what its doing.

    Yeah, the Typed collections caught everyone! LOL
     
  13. mousouchop thread starter macrumors 6502a

    mousouchop

    Joined:
    Oct 22, 2008
    Location:
    New York
    #13
    I actually got yet a another alternative book to learn from that is called Sam's Teach Yourself Java 6 in 21 Days. So I am assuming it will include any new syntax introduced in 6.

    Thanks for the heads up!
     

Share This Page