为具有扎实 C++ 背景的人学习 Java 的最佳方式?(书籍等)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/595491/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Best way to learn Java for someone with a solid C++ background? (books, etc.)
提问by Jim Buck
I've installed Eclipse and the JDK, gone through the "Hello World" tutorial, and read through the Eclipse docs (both about Eclipse itself and developing Java with Eclipse). I'm looking at the JUnit samples to better understand how Java works when it runs.
我已经安装了 Eclipse 和 JDK,完成了“Hello World”教程,并通读了 Eclipse 文档(关于 Eclipse 本身和使用 Eclipse 开发 Java)。我正在查看 JUnit 示例以更好地了解 Java 在运行时的工作方式。
I'm at that point of confusion one gets when learning a new computer language that has newer paradigms, and I think it's partially due to my experience with C++.
当我学习一种具有更新范式的新计算机语言时,我会感到困惑,我认为这部分是由于我在 C++ 方面的经验。
Any suggestions on good Java books/tutorials/etc. for someone with a C/C++ background?
关于好的 Java 书籍/教程/等的任何建议。对于有 C/C++ 背景的人?
回答by Michael Borgwardt
- Start by abandoning eclipse for a while and working just with a text editor and the command line JDK tools, to get a basic understanding of how Java programs work, packages, classpaths and compiler errors.
- Familiarize yourself with the API docs. Start with the crucial classes in java.lang, java.util, java.io and java.text
- Sun's Java Tutorialsare a pretty good starting point for deepening your understanding of specific topics
- The Java Language Specificationand the Java Virtual Machine Specificationcan be a great help for understanding what goes on "under the hood", which is probably comforting for a C++ guy :-). They're quite readable, as specifications go.
- 首先放弃 eclipse 一段时间,只使用文本编辑器和命令行 JDK 工具,对 Java 程序的工作方式、包、类路径和编译器错误有一个基本的了解。
- 熟悉API 文档。从 java.lang、java.util、java.io 和 java.text 中的关键类开始
- Sun 的 Java 教程是加深您对特定主题的理解的一个很好的起点
- 在Java语言规范和Java虚拟机规范对于了解发生的事情,这可能是安慰了C ++的家伙:-)“引擎盖下”有很大的帮助。随着规范的发展,它们的可读性很强。
回答by duffymo
Java's pretty big. I don't know what kind of problems you've been solving with C++, but I'd suggest that you partition Java along these lines:
Java的相当大。我不知道你用 C++ 解决了什么样的问题,但我建议你按照以下方式划分 Java:
Java SE is the core language. It includes the Swing UI classes and JDBC, so it'd be good for writing desktop apps if that's what you've been using C++ for.
Java SE 是核心语言。它包括 Swing UI 类和 JDBC,因此如果您一直在使用 C++,那么它非常适合编写桌面应用程序。
Java EE is built on top of Java SE. It has lots of "enterprise" features, including Java Server Pages, EJBs, messaging, etc., for building distributed, transactional, multi-user applications.
Java EE 构建在 Java SE 之上。它具有许多“企业”功能,包括 Java Server Pages、EJB、消息传递等,用于构建分布式、事务性、多用户应用程序。
If you want to write desktop apps, I'd suggest concentrating on Swing and JDBC. All you'll need is JDK 6 and maybe the relational database of your choice.
如果您想编写桌面应用程序,我建议您专注于 Swing 和 JDBC。您只需要 JDK 6 和您选择的关系数据库。
If you want to write web apps, I'd suggest JSPs written using JSTL and JDBC with a servlet/JSP engine like Tomcat.
如果您想编写 Web 应用程序,我建议使用 JSTL 和 JDBC 编写的 JSP 以及像 Tomcat 这样的 servlet/JSP 引擎。
You can go a long way with just those technologies. As you become more comfortable, expand your circle.
仅使用这些技术,您就可以走很长的路。当你变得更舒服时,扩大你的圈子。
回答by zweiterlinde
I've always found Sun's Java Tutorialto be extraordinarily helpful. You can look up language basics as needed (or breeze through easy sections quickly), but you can easily dive into more advanced topics (GUIs with Swing, concurrency, containers, etc.).
我一直发现Sun 的 Java 教程非常有帮助。您可以根据需要查找语言基础知识(或快速浏览简单的部分),但您可以轻松深入到更高级的主题(带有 Swing、并发、容器等的 GUI)。
回答by Ovi Tisler
Best way to learn it is just to do it. Especially if you can pair-program with a strong Java developer. That's what I did and now I'm much better in Java and find it hard to go back to C++
学习它的最好方法就是去做。特别是如果您可以与强大的 Java 开发人员结对编程。这就是我所做的,现在我在 Java 方面做得更好,并且发现很难回到 C++
回答by Stefan Thyberg
Head First Javaseems to be popular among the people I work with who come from a C++ background. If you like mathematics, solving problems on Project Eulercan also be a lot of fun, doing that with Python now.
Head First Java似乎在与我一起工作的具有 C++ 背景的人中很受欢迎。如果您喜欢数学,在Project Euler上解决问题也会很有趣,现在就用 Python 来解决。
回答by Steve B.
Yes, the libraries are huge, but rather than diving into the swing api, for sheer language familiarity you might be better off writing small pieces that use the collections (the java.util package). I find that this stuff is very central to the day-to-day coding, and it will familiarize you with both generics and the way objects are created, both of which are very different from C++.
是的,库是巨大的,但与其深入了解 Swing api,为了完全熟悉语言,您最好编写使用集合的小块(java.util 包)。我发现这些东西对于日常编码非常重要,它会让您熟悉泛型和创建对象的方式,这两者都与 C++ 非常不同。
I always found Thinking in Javato be a great text, very detailed and well written.
我一直发现Thinking in Java是一本很棒的文本,非常详细且写得很好。
回答by TofuBeer
For getting Javaisms you should read Effective Java 2nd Edition by Joshua Bloch
要获得 Javaism,您应该阅读Joshua Bloch 的 Effective Java 2nd Edition
For unit testing (and more) the Pragmatic Programmersbooks are good.
对于单元测试(以及更多),Pragmatic Programmers书籍很好。
Also a good book for learning Java if you understand C/C++ look at Thinking in Java by Bruce Eckel. This book is good from some points, but falls down on others (he and I disagree on exception handling for one), but if you know C++ it is overall a good book to start with - just make sure you offset it with a couple of Java books that are not for C++ programmers :-)
如果您了解 C/C++,那么这也是一本学习 Java 的好书,请参阅 Bruce Eckel 的 Thinking in Java。这本书在某些方面很好,但在其他方面却不尽如人意(他和我在异常处理方面存在分歧),但是如果您了解 C++,那么它总体上是一本好书 - 只需确保您用几个来抵消它不适合 C++ 程序员的 Java 书籍 :-)
For learning Java, well the core language is fairly similar to C++. Back in 1995 it took me about one day to get comfortable with Java, 3-5 days to figure out the ways it was different than C++, and about a month to learn the libraries.
对于学习 Java,核心语言与 C++ 非常相似。早在 1995 年,我花了大约一天的时间来熟悉 Java,3-5 天的时间来弄清楚它与 C++ 的不同之处,以及大约一个月的时间来学习库。
Java has changed a lot since 1995 though... so one day is still prbably accurate for the first part. From a language point, depending on what you want to pick up, say a week. The library... well that could take years (at least months) depending on what you focus on.
Java 自 1995 年以来发生了很大变化……所以有一天对于第一部分来说仍然是准确的。从语言角度来看,取决于你想学习什么,比如一周。图书馆……好吧,这可能需要数年(至少数月)时间,具体取决于您关注的内容。
回答by Michael Myers
回答by Hyman BeNimble
I particularly agree with these suggestions:
我特别同意这些建议:
Get Java Programmer Certification. This is a great intro to the language, not expensive, and really gives you good idea feel for the core Java language. It can definitely help on a resume, e.g. that along with the Java Developer certification helped get me my first job in Java. Check out JavaRanch for online cert help.
获得 Java 程序员认证。这是该语言的一个很好的介绍,并不昂贵,并且确实让您对核心 Java 语言有很好的感觉。它对简历肯定有帮助,例如,与 Java 开发人员认证一起帮助我获得了我的第一份 Java 工作。查看 JavaRanch 以获取在线证书帮助。
Read Bruce Eckel's Thinking In Java. It's free online! Great book.
阅读 Bruce Eckel 的 Java 思维。它是免费的在线!很棒的书。
Sun's Java Tutorials. very helpful.
Sun 的 Java 教程。很有帮助。
For reference, use the online Sun Java Docs, and Java Almanac (on the web). Java Almanac is all code samples.
作为参考,请使用在线 Sun Java Docs 和 Java Almanac(在网络上)。Java Almanac 是所有代码示例。
回答by bpapa
Books are fun but learn by doing. Build an app.
书很有趣,但要边做边学。构建应用程序。

