I've been using C++ for about 6 or 7 years now, and I consider myself fluent in it. I've never bothered with Java until now, but I find myself out of the job (company went under) and I need to expand my skill set. Someone recommended Java, so I am wondering if there is any advice for where somebody like me might start. I am also interested to know what the key aspects of Java are that are most likely to come up in an interview.
There are some popular areas that I think of when we talk about Java
Concepts of OOP: I'm sure this will not be much different from C++:
Class, Abstract Class, Interface,
Polymorphism, Overriding,
Overloading, Inheritance, Static
member, ... Interface will likely be
area that you might want to focus.
Since this is not directly available
in C++, I don't know.
Core Java: Such as the basic syntax and the common classes such
as Math, String, System.out,
Scanner, Basic file I/O, Stream.
Know the concept of Garbage
Collection, Reference Type (since
pointers are not available here.)
Know the Java platform/technologies,
J2SE, J2EE. Basic GUI with Swing and
its layout managers. Web
Applications with Servlet/JSP.
Popular tools, frameworks, and libraries: This may not as
important as above bullets. But
maybe you should know what Eclipse,
Netbeans, Spring, Struts, Hibernate,
EJB, Ant, JUnit, JavaDoc, are for.
You can always search for "C++ to Java" in Google. I'm sure there will plenty of good start points. Don't forget not to put * in front of var name next time you code Java :)
I recommend you read the book Effective Java cover to cover. Not only will you learn lots of good programming practices, but you will also learn more about Java than you otherwise would. Highly recommended. :-)
As a simple example, in Java, rather than rolling bitfields by hand (which is rather painful to do in Java, and for good reason), you use an EnumSet instead. This is documented in Item 32.
BTW, if you don't mind reading a PDF (no DRM) version, it's cheaper than hardcopy too: http://www.informit.com/title/0132345285
There are a number of great "in depth" Java books that will teach you not only Java, but also best programming practices.
If you're just interested in syntax and an introduction to the Class Hierarchy, Java in 24 hours is pretty good. From there, you will know enough to go and explore more on your own.
I highly recommend thinking of a small project to help you learn. In fact, think of a teeny tiny project -- it will turn out much bigger than you think! ;) Maybe a simple shoot-em-up or a Daleks- or Asteroids-alike, or some such.
The main thing being: for an expert-level programmer, don't try to learn Java from a book. You can get introduced to Java via a book, but then you have to go learn on your own (or from another.) It's like learning to drive a car -- you can get the basics from a book, but you need to explore & try stuff, and someone who knows how can be very helpful.
Some things that will help:
Download and bookmark the HTML Java docs. You will reference them often.
Have a small project, a simple game or utility app that you estimate will take a couple of days to write. Spend a couple of weeks writing it ;)
Note that "Java" is 3 things:
Java the programming language. Like C++ or Lisp or Perl.
Java the Class Hierarchy. Like STL or Cocoa.
Java the run-time virtual machine, the JVM.
People use the word "Java" to mean all 3 things, and slip between them without much notice, so pay attention to that, when you start talking Java to people.
Good luck!
(And let us know when your game is available :)
The biggest issue with the C++ to Java conversion is that they're so similar -- you'll find yourself doing C++-isms for a while. But it's no big deal: as suggested, read Josh Bloch's book, and run through the tutorials on java.sun.com and you'll do fine.
In my opinion, Java sets itself apart from C++ in three ways:
Automated memory management
Simplified syntax (and no preprocessor)
The Java standard libraries
As a former C++ guy, the first two shouldn't be a problem. (In fact, I would wager they will strike you as rather refreshing.) To get used to the libraries, I recommend Bruce Eckel's Thinking in Java - the 3rd edition is free to download. Though the beginning chapters will probably be a little too basic, the sections about GUI programming, concurrency, and the various container classes will be very helpful.
Beyond that, the best way to learn any language is to read good code.
I started by reading the Java Language Specification, version 2 at the time (2001).
In my view it is quite readable as specifications go.
Effective Java is good advice.
Java Puzzlers is good to learn corner cases and possible pitfalls.
The Peter Norton's Guide to Java Programming, "Making the Transition from C/C++ to Java".
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I studied 2 courses in Java:
1- Introduction to programming with Java.
2- Data structures with Java.
In Both courses we used Java SE.
I loved it and I really want to be a great java programmer.
But, I discovered that I should know many technologies involved in Java software development:
Spring, Struts, JSP, JSF, GWT, Hibernate, apache tomcat and many more actually a lot more.
I hope it become simple process like .NET
you choose one language with one framework and IDE that is it.
Could anyone guide me to the best route or path to master Java, please?
What do you think about these two courses:
http://www.oreillyschool.com/certificates/java-programming.php
and
Advanced Java Certificate Series (from the same school, will be available in September).
I think most programmers have about average college graduate intelligence, including myself. What we do have a lot of though is patience.
That said, there are efficient ways to learn and inefficient ways to learn.
If you're stuck on one tutorial/book, try another book. Once you're done with the basics, there really is no "correct" order to learn.
Skim through the standard Java library documentation. Don't bother memorizing it, but be sure that you know the tools are there when you need them.
Make lots of test programs. If you're ever curious about something, try it out and see what happens. Don't know how big an int is? Write a program that prints out a sizeof. Don't know what happens when you call a virtual function of an override instance? Write a program with two classes, one inheriting the other, and try it out.
Read other people's code. Take note of style and structure. And I don't mean silly things like whether the { should go on the same line as the statement, but how they recycle variables, how they organize their classes, how they use loops, where they bother to optimize and where they don't etc. Emulate what you like.
Practice building "stub" programs -- you can do this in your head once you get the hang of it. Find your favorite program, and write out all the classes/methods as you think would have been used to build it. That'll help you with architecture.
Spend lots of time naming your classes. Don't use fancy names, just descriptive ones. It's a good mental exercise to think about names, even if you don't expect to ever share your code.
Try Project Euler if you're into that sort of nitty-gritty mathy stuff. I don't believe that programming is all about math, but you might like it.
Learn C sometime. C++ probably isn't worth it if you're doing java, but C will teach you how your computer works. You don't need to master it, but at least get to the point where you understand memory management and pointers. That'll help you make decisions faster when you want your code to be really fast.
Learn functional programming someday. Haskell's a good choice, because it's a pure functional language. It's extremely difficult at first, but the concepts you learn from it are valuable regardless of what language you program in. You'll be making design decisions a lot faster, and your code will be a lot more robust.
Keep up to date. Trends come and go in this industry as fast as in the fashion industry. A lot of it is crap, but a lot of it is crucial both to employment and productivity. Always keep an eye out, or you'll go the way of the dinosaurs.
The best way to become good at something? Practice, practice, practice.
Don't focus on a single framework just do lots of Java, take a look around open-source projects, find something that needs fixing or implementing and do it or think of something that you want but doesn't exist and make it.
Practice doesn't make perfect - perfect practice makes perfect. If you continue to make the same mistakes, you'll only succeed in developing bad habits.
You need to read this.
Your Java roadmap ought to look like this:
Concentrate on core Java JDK classes to start. Don't worry about Java EE until you're comfortable with interfaces, classes, and the basics. JDBC is an important part of core Java, so be fluent with it. You'll have to know about relational databases, normalization, and SQL. GUI technology here is Swing.
Once you have that, take up servlets, JSPs written using JSTL exclusively (no scriptlets), and JDBC. You'll have to understand something about Tomcat (or another servlet/JSP engine), HTTP, HTML, CSS, and a little JavaScript as well. You can go a very long way with just these.
Once you've mastered 1 and 2, you'll have to make a choice of framework. I'd recommend either swallowing Spring or EJB 3 whole. I'd recommend Spring first, but I'll admit that I don't know EJB 3 well.
I get the impression from the phrasing of your question that Java is your first programming language. I laud your desire to "master Java", but if I might, I'd like to suggest that you try a little breadth before you get too much depth!
It's easy, I think, with a CS degree where most courses are taught in Java, to fall into the trap of believing that all programming languages are:
object-oriented (and with single implementation inheritance and multiple interface inheritance)
statically-typed (with no type-inference)
imperative (i.e. making use of iteration constructs and mutable state)
verbose
and therefore that all programming must look roughly like Java programming.
I'd humbly suggest doing some reading on different paradigms and languages: learn a dynamically typed language (coming from Java, I'd suggest Python or Ruby), learn a non-OO language (like C)---and implement OO, learn about functional programming (Haskell's a great eye-opener). At least take a look around before diving head-first into Java alphabet soup (Java culture highly values acronyms---but I'll pass no value judgments on this here).
Just my US $0.02!
Write programs in it. Find open source programs that use it and fix their bugs and add functionality to them. The best way to get experience is to experience it.
If you really want to know what you should be studying, within the realm of your examples (Spring, Struts, JSP, JSF, GWT, Hibernate, apache tomcat), then find some podcasts and blog posts that allow you to survey these technologies. You can then choose the ones you are most interested in for further study.
I agree with the other two respondents (practice, particularly with open-source projects, is the best way to get good at a language). However, I wanted to add one thing. It's unclear from your answer how much experience you have with object-oriented design, and with Java, that's essential. I'd recommend looking into advanced OO design to get a sense for what's out there. My favorite book on OO design is available for free and linked below - see if it's at your level. If not, find something more/less advanced and work from it.
http://homepage.mac.com/s_lott/books/oodesign/build-java/html/index.html
Java Technologies are very vast, from mobile phones, to enterprise level servers. You might want to first narrow what you want to learn.
Your first talk about Java SE(applications programming) and then start mixing in Java J2EE, and Java EJB.
If you want to go down the web route or enterprise server then you need to learn J2EE,EJB,Hibernate,Spring,etc otherwise these technologies aren't seen as often when programming applications.
It still seems like you have a long road to go, probably the most beneficial for you to learn next would be Java Swing(gui).
Practice and learn frameworks as you need them (or come across them). There are way too many frameworks out there (for Java and for .NET) to learn in one shot.
Learning the standard Java class libraries is always a start
The best way to become good at something? Get a job that allows you to use that technology. Get paid while practicing.
There is a time to stop reading books and articles, and get to work building a project.
As you are working, learn from others who are better than you. Continue to read articles on topics that interest you, and apply what you learn at work.
Find a mentor and pick his/her brains often. Once you are working in the field ask for code reviews from senior developers. This will get you out of your own habits, and reading people's suggestions for how you can improve will give you plenty of insights. Don't sit around reading, solve problems on a per-problem basis and work your way up from there.
Its not that easy to became a master in Java, what i have done to study java is
1)try to convert all the apps i have seen into java,
eg:paint to java
2)used to went to JAVA user groups and conference in my state
3)Went to Groups in Goolge for checking Codes of Java
thats all i do, i cant say i am the master, but i am able to do the stuff
I am going to begin my Computer Science & Information Systems degree in April. My first class is an introduction to Java programming.
Lately I have had an interest in Objective-C, but slowly declined due to lack of persistence and comprehension difficulties, (mostly some OOP). Obviously I would like to do well in my classes, so I am asking what is the best way for me to prepare?
Should I complete the Alice training and then start learning some Java on my own? Continue to work through Objective-C religiously until I see results? What do you think a newby should do?
edit: I have been reading reviews for a lot of Java books, just curious, are there any other well written beginner books? Thanks!
Objective-C probably has some barriers that will be problematic if you're learning.
I would suggest picking up a copy of either Thinking in Java or Head First Java and reading through that to get started.
When you're learning it can be useful to not be distracted by too many details. Master the basics. Learn about basic OO design. Frustration is the biggest enemy. If what you're doing seems daunting, the greater the chance you'll just give up. So keep it simple so each time you do something it feels like you're making progress.
Firstly pick one of the two languages, either Objective-C or Java, as learning both at once might not give you encouraging results and you're gonna have a lot on your hands than you can handle at one time. So, I'd suggest you go ahead with Java as Java is also going to be your first class. Java is huge, so keep it simple in the beginning and concentrate more on the fundamentals and you can build on top of that as you progress. And you can always ask questions here on SO. Also you probably might find the java classes easy as you've already been doing your homework.
In addition to the java books already mentioned, I'd suggest you go ahead with the Sun's java tutorials.
As a java beginner, you might also find this free book helpful:
http://www.greenteapress.com/thinkapjava/
I think one of the best ways of learning the basics of programming these days is by playing with Ruby. You will have to spend something close to 0% of your time worrying about infrastructure issues (compilers, header search paths, etc), and you can experiment with the interactive mode (irb) to rapidly learn how to use various features.
You can start out with Ruby without having any concept of what objects or functions are, yet you will gradually learn about quite advanced object oriented topics, and even functional programming-style patterns.
Chris Pine's "Learn to Program" teaches the basics of programming using Ruby. I haven't read it, but had a look and it made a good impression.
(There are also many other books teaching Ruby.)
There is nothing inherently bad about learning programming through Java, and it gives you a general understanding of OO design, but it is a pretty limited language. Ruby is just much more fun and you get to learn a lot of advanced techniques that aren't even possible to use in Java by just experimenting with it––many of which will be useful when you're learning Objective-C later.
Using my not-outstanding Google skills, I have not been able to find a decent tutorial on Groovy for Ruby programmers. There are a lot of political pieces (Ruby is great! Groovy is great!) and tiny little contrasts, but I really don't care which is better. I know Ruby (and Java) relatively well, and I'd like to learn Groovy.
Would anybody care to (either provide an amazing link or) mark some differences between the two languages in terms of how to do things (syntactic, class declaration, loops, blocks, etc.)? For my purposes you can assume full Java competence to explain.
Again, I am not interested in knowing which is better. Just need to know how to do stuff....
If you know Java, the best thing you can read is how the metaClass is used in Groovy. Here's a decent explanation: http://skillsmatter.com/downloads/Groovy%20User%20Group%20December%202006.pdf
Just remember that everything in Groovy runs through the metaClass. The seemingly simple statements:
a = foo.bar
bar = b
foo.baz(1,2,3)
Translate roughly into this Java:
a = foo.getMetaClass().getProperty("bar");
this.getMetaClass().setProperty("bar",b);
foo.getMetaClass().invokeMethod("baz",new Object[] {1,2,3});
Everything is dispatched through the metaClass, which is how pretty much all the Groovy "language" features work. The most important feature is probably closures. What you need to remember about closures is that it's all metaClass trickery. The closure's metaClass can be setup to try invoking methods/resolve properties on its delegate, which basically means you can do things like invoke a method on an object that doesn't have that method.
Did you see this and this?
Relatively short posts, I know. You're right; there doesn't appear to be much...
update: two more links.
We need more questions like this one. Three years after the question, there's still a comparitive lack of information on this moving betwen these two similar languages.
I did find this Slide Share presentation, which covers a lot of basic ground.
Comparing groovy and (j)ruby
And this blog post was helpful with 'simple' stuff because it give a bit more background:
Thoughts on Groovy
The reasons to switch between languages usually have more to do with project needs than a language itself and I feel its important able to swap and compare between tools.
One standard resource for this kind of question is: Rosetta Code.
Hope to see some more tips added to this list.
Cheers,
Will
The differences between Java and Groovy are less than the differences between Ruby and Groovy, so if you know both Ruby and Java, it probably makes more sense to look for a "Groovy for Java programmers" book or tutorial.
IMO, the best Groovy book on the market is Programming Groovy. It's the most up-to-date book that I know of (though still a few versions behind the latest release), is pretty concise, and covers some relatively advanced topics in quite a bit of detail (e.g. meta object protocol).
The Groovy wiki has a good article entitled Groovy style and language feature guidelines for Java developers.
Alright, so here is a breakdown of my situation.
I just finished my first year of 'computer science' in Highschool, learning the fabulous language, Vb.net (get your laughter out now)
I am going into AP computer science next year. We will be working with Java.
I have tons of free time this summer and I would like to improve my programming skills and become a more efficient programmer.
I will be using the BlueJ IDE for Java
Do you think I could learn to program in Java before September?
What exercises would you recommend for a novice programmer to get rid of the bad habits that I may or may not have acquired while programming in vb.net?
How hard is the transition of VB.net to Java?
Would it be easy to work with different IDEs or should I just stick to a single IDE?
The Java Tutorials would be a good place to start learning Java.
If the idea is to start out fresh and try to get rid of the "bad habits" (of course, using Visual Basic .NET doesn't necessarily mean that you may have picked up bad habits), it wouldn't hurt to take a look at the tutorial from the beginning.
As for the single or multiple IDE situation, at the beginning, I would say starting with one and getting somewhat comfortable wouldn't hurt.
Actually, it might not be such a bad idea to skip the IDE at the beginning and use a text editor and the command line to compile and run programs.
Why? I've noticed that many people who rely only on IDEs don't know the basics of how to compile and run programs, and as a result, have less of an understanding how to actually get things running at the basic level, because the IDE takes care of it for them.
I haven't used VB .NET myself, but I would suspect that if you've programmed in an object-oriented manner, the transition from VB .NET to Java probably isn't going to be a big leap. However, if object-oriented programming seems difficult, then starting out with an IDE like BlueJ (which I've only used a couple times, a few years back) at the beginning might be easier.
Learning Java before September is totally doable, but there is a lot of upfront learning especially with IDEs that could create motivation issues. Java is much stricter than VB, so the transition might seem pretty odd.
Personally, just coming from my interests, I would take a gradual approach by starting with Processing (http://processing.org/). Processing is Java, but designed for making digital art. It also defers the need for a lot of the boilerplate stuff until you have a need for it. I've found that the learning curve is pretty gentle and the skills translate well. Also, coding up pretty pictures or simple pong implementations is a lot more fun (at least for me) than writing "Hello World".
I transitioned from QBASIC to C++ and then Java and other languages. It's really not too bad.
Good Luck
Well, syntax-wise VB.NET and Java aren't very much alike but in my experience syntax is the least of the problems in learning a new language.
You certainly have to come to grips with the standard class library of Java which is a little differently organized than .NET, although it contains essentially almost the same stuff.
What's more is that Java has very little syntactic sugar to make tasks easy for you. Writing larger programs alsmost invariably need design patterns and Java is a language which is pretty heavy on those. Learning them and knowing when to use them (or at least spot them in the class library) might take some time, unless you already have knowledge in that area.
For example while in VB.NET you have events for propagating messages between objects such a concept does not exist directly in the Java world. There's the observer pattern for that kind of thing. Depending on how you look at it, .NET events are just syntax sugar for the observer pattern, going on below the hood unbeknownst to the beginning programmer, or .NET simply doesn't have the need to approximate a solution with classes and interfaces where a proper one is already in place.
Actually, my biggest gripe with Java is verbosity and the fact that nearly everything has to be a class.
But for learning, I'd suggest you try just diving right in. There are a whole lot of tutorials out there to help you get started (Sun has many good ones covering key aspects of the Java platform). You can redo a project you already done in VB or come up with a task you want to solve yourself (although I'm not very good at such things, ymmv :-)).
But the easiest way to learn a language is to actually program in it. You'll certainly be no expert until September but solving some problems should be entirely doable. Also, I doubt they'll expecting you to have already mastered the language by then.
As for IDEs we use Eclipse a lot around here and just grazed BlueJ during a single lecture. I'd say you should use what works best for you, although I remember BlueJ not so much as an IDE but rather an interactive Java playground or so. I may be mistaken though as I regularly didn't pay attention to the lectures at that time :-).
Let me first of all say that I'm NOT interested in a flame war about what is better: .NET or Java... PLEASE don't post if you want to tell me how killer .NET is or how Microsoft is the evil empire so there is no way that a developer with a soul could write .NET or whatever. We've all heard it far too much before.
What I'm interested is who out there in the industry can really accurately and fairly compare and contrast the details of the two platforms. I'm looking for the rare industry luminaries who are experts in both platforms and discuss the two in reasonable terms. The only dude I'm aware of in this realm is Ted Neward if that gives you an idea of what I'm looking for. Ultimately I'm interested in their opinion of how the two platforms influence each other and what new things happening on one side are working well (which might give me insight about how the other platform is likely to evolve).
Martin Fowler has written about both.
Ron Jeffries would be another who has written a lot about java and has more recently written a fair bit about C#
I'm no Ted Neward, but I'm reasonably experienced in both Java and C#.
Despite Microsoft's early draft of the C# spec claiming that it is a mixture of C++ and VB, clearly Java was a massive influence. Since C# 1.0, however, I would argue that C# has been the language driving innovation. (Okay, a lot of the new features have already been present in other languages, but not Java...)
A lot of the proposed features from Java 7 look very much like they've been influenced by C#, but I wouldn't be surprised if they were under consideration before C# got them (just like generics in Java were being developed for years, and in the other direction there were research projects with generics in .NET before .NET 1.0 was even released).
What does the future hold? Well, personally I'd like to see a true Java 2.0 which ditches backward compatibility in order to clean up some of the messes of the past - and largely make it like C#, but with the existing platform independence. Nothing in the language of C# is tied to Windows. From that side of things, it's a real shame that Mono hasn't gone further (or been supported by Microsoft, other than Moonlight).
I have worked with both platforms since .NET was created, mostly in dual-language projects.
Java is the "spanish" of languages (written spanish has changed little for the last few hundred years or so), C# is english (most of us are unable to read 200 year old english literature)
C# has "all the bells and whistles" added nice and clean into the language. Java is fairly primitive in comparison.
Java has a huge choice of competing libraries and different ways/styles of coding, .NET is much more "single choice"; often a good choice has been done by microsoft for you. These arguments objectively lead no-place in particular; some people may consider having a lot choice is good, others may think it is an unnecessary expense. My current java project is using NONE of the libraries I used in a similar project 5 years ago; so although the language is the same the programming environment (libraries, IDE) has improved by an astonishing amount.
So as a developer I prefer C#. Still, by choice, I work in Java right now, and will continue to do so for the foreseeable future - still by choice. Although java the language evolves painfully slowly, there area a lot of really interesting things going on in java. The rest of my choice is based on all the things you specifically don't want to talk about; openness, the dark side and all that.
The company I work for has about half of it's development in Java (internal apps) and half in .Net (public facing apps). What is it that you want to know? there are several people in the company I work at that can contrast and compare. I admit to not knowing Java all that well though. Are you looking for specific articles, bloggers, or books?
If you are looking for a person which has compaired both frameworks Java vs .Net, then I do not have a name, however there is one KEY phrase I would like to make you very aware of
Type erasure
Generics in Java <- its mentioned here, I came accorss this by word of a work friend. (Im not sure when there will be a fix for this)
This would mean java will always be boxing and unboxing.
with reference to krosenvold
Java has a huge choice of libraries
and different ways of coding, .NET is
much more "single choice". This is
good and bad both ways.
Im not quite sure what he means by this. If i were to second guess this, you are referencing .Net's DataTable. and how .Net (used) to be data centric not domain driven?
If so I would like to mention .Net has a movement called "Alt.Net" AKA "NHibernate Mafia" where there are a number of open source libraries to allow the .net developer to do ORM/DI/MVC/TDD etc. With many of the libraries having roots from the Java world (spring, hibernate) However this is not core to the .Net or even Java Frameworks.
I would suggest considering what you want to compare.
for instance
Frameworks (including the
community/opensource ones)
Limitations (Java is 1 language, but
works on multi OS, .Net is multi
languge, yet "offically" supports
windows platforms, using Mono)
Avaliable IDE's
Here are some links to get you started.
Comparison of the Java and .Net platforms
Comparison of Csharp and Java (look for instance, they handle Enumerations differently)
HTH
Bones