In my experience, Java is very easy to learn and the language much more friendly than C++.
Additionally, Java provides a huge variety of implementations for the most common data structures (queues, lists, hash tables, etc), so you do not need to implement them and you code more focused on the problem.
I'll second Adrian's response. Though possible with C++ (and add on libraries - such as STL), more 'stuff' is done for you in Java. Most of the basic data structures you've listed are already there - if you bring in the right classes for inheritance.
Additionally, STL (for C++) isn't implemented with every compiler, so Java having the data structures already defined as part of the 'standard' make life much easier.
Java. I find knowing C makes C++ far easier to utilize (as you know how to better implement software by exploiting its features more appropriately). I'd put C# and Java on the same level of difficulty for students to learn.
It is easier and faster(in terms of implementation time) implement data structures in java, the language provide a lot of facilities, but if you refer faster as, time of execution and also with low resources in you computer C++ is the best choise, but is a little hard learn it.
People often find it more easy to programme in Java instead of C++. This is true since most of them does not truly understand the use of pointers in the latter programming language, and especially students. If someone overcomes this problem then C++ is his/her case. It comes with support of several containers in STL and also support for the Boost C++ libraries. On the other way, learning data structures in Java might be more efficient and less distracting.
I'd the say the answer to the question depends on whether you are more familiar with Java or C++. Both languages have extensive data structure support in their standard library. Having used both, I would say C++'s is probably slightly better documented, with better performance guarantees.
Yes it is true that Java is a simpler language, and is easier to learn. That probably makes hiring good Java programmers easier than good C++ programmers - you could argue the point anyway. But it does not make Java an easier language to use for competent programmers. There are considerable pain points in Java (such as frequent testing of types before casting and checking for null references that are not necessary in C++ if you're coding correctly). And generics are completely botched up in Java, don't get me started. Nevertheless, I would say that a competent programmer in either language would probably be of similar speed and efficiency for implementing large, complex pieces of software.
@Jerrold Hyman - the STL is part of standard C++98, and every release of C++ thereafter. You would have to have an extremely ancient compiler not to have STL out of the box. FWIW, container support in Java was exteremely primitive before generics were introduced in version 5.
@Zhijun - yes, but its generally not a massive difference. My experience is that Java is usually within a factor of 2 of equivalent C++ code, assuming both implementations are competently coded.
I've worked for 7-10 years in each language, so I'll bail in to this language dust up.
As several have noted, it depends you mean by faster and easier". C++ definitely can outperform Java, but it's also possible to write C++ that has abysmal performance. Java's current incarnation from Oracle includes a just-in-time compiler, so code that is executed heavily will be compiled down to machine language, just like C++ is. The major performance pain is the time to start the Java virtual machine (JVM). It is worth noting that if you are using Microsoft products and "Managed code" in C++, you pay a performance hit for the .NET just in time compiler.
Most people find Java easier to work in. Memory management is the big advantage, and removes a whole class of errors (memory leaks and dereferencing pointer to memory that has been freed for example). And, as Antonios Gouglidis notes, pointers are a concept that beginners find very hard to wrap their heads around. Most of the data structures you mention lend themselves to pointer-based implementations, so this can be another barrier for inexperienced programmers.
The Java ecosystem is huge, with a staggering number of open source libraries for virtually any need (I at least) could imagine. So one doesn't need to implement most things. For example, the Apache commons math library contains a wealth of statistical distributions, optimization routines and other sundry treats. A search (either Google or on the site) of SourceForge, google code, github, bitbucket or CodePlex generally pays off handsomely. This is also true of C++ (and virtually any other language you can name), but Java is particularly rich.
@Russell Standish
There are lots of pluses and minuses, and all languages have their own sharp corners. Java's generics are certainly complicated for the inexperienced. On the other hand, they don't yield the "template bloat" you see in C++, and the don't break any legacy code. I do agree with the main point, though. A good programmer can handle either language. Heck I've seen people do some fantastic things in Perl (you couldn't pay me enough; well, maybe...), and I'm sure there is COBOL somewhere that sings, too.
A major weakness of C++ is the lack of reflection. Boost (see below) cobbles some reflection together for C++, but spend a month working in one of the good Java IDEs (eclipse, netbeans or IntelliJ) for Java (with continuous compiling in the background, and very strong auto-completion) and then go back to writing C++; it is a splash in the face with very cold water indeed. Similarly, look at unit testing frameworks like JUnit or TestNG, and compare them to their C++ counterparts (like CppUnit) to get a sense of how the lack of reflection can be a pain point.
Similarly, the Exception semantics of C++ are murky at best. Take a look at Herb Sutter's (www.herbsutter.com) writings on this from the early 2000s to see what I mean.
A few of other tangential points:
In much of computing there is hand-wringing over what to do about the current shift from faster and faster CPUs to multiple cores. Taking advantage of multiple cores requires multiple threads, which are a black art. Both C++ and Java-based languages (see below) are adding features to support the multi-threaded programs. Contrary to common belief, multi-thread programs are *not* hard to write. They are devilishly hard to write correctly, and debugging race conditions is a nightmare.
In Java, there is a growing tendency to use newer, non-Java languages in that run on the JVM. Scala, Clojure and Groovy all have growing user bases. Scala and Clojure are both aimed at introducing functional programming concepts to the JVM. Clojure is a Lisp variant, and Scala is a hybrid functional/object oriented language. Both aim at taking advantage of the current CPU trend toward multiple cores, by introducing new constructs and emphasizing immutable objects.
In a different direction, Groovy is a dynamic language (like Python or Ruby). As a result, Groovy is much simpler to develop in, while simultaneously having some serious power tools available, such a sophisticated meta-programming model. For web development, the Groovy-based framework Grails is gaining substantial attention.
On the C++ side, the current C++ standard was finalized last year. This goes miles beyond simple STL. It contains substantial support for multi-threading, plus a beefed up standard library. As always, the compilers lag somewhat behind (say a decade) implementing the full standard. If one's compiler doesn't provide everything, the first stop should be the Boost (www.boost.org) project. It is a treasure trove, and implemented by the people proposing additions/writing the standard.
Another seldom noted C++ goody is "template metaprogramming", where the pre-processor is used to expand templates into pre-computed quantities. Blitz++ was the early pioneer and has some really slick stuff if one is doing linear algebra computing. A(nother) downside of Java's implementation of generics is that it doesn't allow this kind of mind-bending (nor do the templates in C#, for that matter).
If learning is involved by practicals, then definitely C++ is the choice (without using STL). Because, students must know how a library can be implemented under the hood. C would have been better choice but as one of the JAVA or C++ was required to be chosen, I definitely recommend for C++. Otherwise, I have similar opinion as most of the technocrats mentioned above.
In my above response, I am not saying JAVA is better. I am saying JAVA is simpler. Of course C++ is better and faster to compile ad work. But JAVA is faster to code (since it is simpler). Visual Basic is simpler than both and faster to code, but does it mean VB is better? Of course not. C++ is the best ever!
Java has Built in library for different data structure called collection. therefore you implement you algorithm easily in java there is no need of reinvent the wheel. in C++ you must create you own classes for data structures.
Although Java libraries/classes for data structures like Collection are easier to use in the sense that the names are more readable but when it comes to power and performance, C++ always has a definitive edge. C++ also have libraries like Standard Template Library, which has pretty much everything to represent different data structures and it is way faster than Java. C++ is more powerful than Java in many ways like IO, access to low level resources directly, having availability of low level APIs to access hardware resources and provides the flexibility to the developer to work native to the operating system where the application will run.
In my opinion, if it is for educational purposes I will choose java. C++ is too powerful and flexible and sometimes students do not see the OOP concepts clearly
Never ask such questions in public because you will immediately have a little holly war in comments.
If you just want your work fast and dirty than answer is neither. Take Groovy, Python or any other high level scripting language. Of course you will lose both performance and reliability, but it will be very fast and simple.
If on the other hand the main thing you need is performance of code - perhaps your solution is C++. It is indeed fast (benchmarks show that it outperforms java from 20 to 60% in different tasks).
If you need reliability and portability - then the answer is java.
My personal choice is Java because it much more reliable and bug-proof for large scale development. Also in my experience, one needs to be a pretty good programmer to write good and fast code in C++. Most of the C++ code you can find over the internet is... well... not very good.
IMHO, I think C++ is faster, but Java is easier to implement data structures. Java is a defacto standard of programming language in higher education, so you can easily find data structures textbooks in Java than C++.
I choose Java for teaching my students in university.
I've recently implemented some cache-oblivious algorithms and data structures with both languages (Java and C++). So based on my experience C++ is more powerful than Java for implementation of cache oblivious data structures (support for large dataset and closer to the hardware can be some of reasons).
Let me confess from outright that I'm a C fan. For speed, C++ will beat Java hands down. For ease, java's OO is better than C++. It's still pretty close, but there are a lot more pitfalls with C++ than Java. I guess it depends on what you are actually looking for. I recently had a situation where the algorithm I wanted was only in Java or python and I needed C/C++. I translated the Java code to C++ which was a lil painful at times. But the end results of course was that it was much faster. And then I needed a lil more speed so I wrote it in plain C. But each time, it was a lil more painful. The difference in speed for Java and C/C++ is the JVM. Java runs on the JVM which translates the bytcode to machine language but C++ gets compiled directly to the machine.