从 Python 背景学习 Java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1883455/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:22:22  来源:igfitidea点击:

Learn Java from Python background

javapython

提问by Nick Meharry

I have been programming in Python for a while now, and I'd like to learn a more "hireable" language like Java or the C/C++/C# family. I'm acquainted with (though not necessarily good at) all of them. I'm leaning towards Java because it runs just about everywhere, and I'd like to start developing for the Android.

我已经用 Python 编程一段时间了,我想学习一种更“可雇用”的语言,如 Java 或 C/C++/C# 系列。我熟悉(虽然不一定擅长)所有这些。我倾向于使用 Java,因为它几乎可以在任何地方运行,而且我想开始为 Android 进行开发。

Coming from a dynamic language, what is the best way for me to learn Java? Or should I learn a C based language instead?

来自动态语言,我学习 Java 的最佳方式是什么?还是我应该学习基于 C 的语言?

回答by Erich Douglass

I would take a project you've implemented in Python and try converting it to Java. Since you already know basic programming fundamentals, it'll probably be easier if you take things you know how to do and figure out how you'd do the same sort of operations in Java (or whatever new language you want to learn).

我会拿一个你用 Python 实现的项目并尝试将它转换为 Java。由于您已经了解基本的编程基础知识,因此如果您采用自己知道如何做的事情并弄清楚如何在 Java(或您想学习的任何新语言)中执行相同类型的操作,可能会更容易。

In the end, the only way to learn to write code, is to write more code.

最后,学习写代码的唯一方法,就是写更多的代码。

回答by Greg Graham

Java and C# will be less of a step away from Python than would C or C++ because Java, C#, and Python all have automatic memory management. A good Java book is Thinking in Javaby Bruce Eckel. It starts at an introductory level, but also has a lot of depth.

Java 和 C# 将比 C 或 C++ 更远离 Python,因为 Java、C# 和 Python 都具有自动内存管理。一本很好的 Java 书是Bruce Eckel 的Thinking in Java。它从入门级开始,但也有很多深度。

The big difference with the language coming from Python is the fact that all variables are typed. The other hard thing with Java has to do with the bewildering array of Java APIs out there. The fact that you are interested in Android is an advantage here. After becoming comfortable with the core language, I suggest you start learning the Android API and focus on becoming an Android expert. I think Android will be a growing market for a while.

与来自 Python 的语言的最大区别在于所有变量都是类型化的。Java 的另一个难题与令人眼花缭乱的 Java API 阵列有关。您对 Android 感兴趣这一事实在这里是一个优势。在熟悉了核心语言之后,我建议你开始学习 Android API 并专注于成为一名 Android 专家。我认为 Android 将在一段时间内成为一个不断增长的市场。

Good luck!

祝你好运!

回答by alexako

Here's a good pdf that introduces Java for Python programmers:

这是一个很好的 pdf,它为 Python 程序员介绍了 Java:

http://interactivepython.org/runestone/static/java4python/Java4Python.html

http://interactivepython.org/runestone/static/java4python/Java4Python.html

I'm going through it now myself. The author compares Python code snippets with Java equivalents and thoroughly explains each line of the Java snippet. However, the book is short and glosses over a lot of material. While I feel that it does help me relate to the new language, it must be supplemented with more thorough books. Head First Java and Thinking in Java seem to come highly recommended. I'll be moving onto those after I finish up here.

我现在正在经历它自己。作者将 Python 代码片段与 Java 等效代码进行了比较,并彻底解释了 Java 代码片段的每一行。然而,这本书很短,掩盖了很多材料。虽然我觉得它确实帮助我了解新语言,但必须辅以更全面的书籍。Head First Java 和 Thinking in Java 似乎是强烈推荐的。在我完成这里之后,我将转向那些。

回答by Amir Afghani

The best way to learn is to just start programming. Pick a project like Chess or Checkers and start writing code. Get a book like Java How to Program, go through the examples and exercises and oh yeah....keep writing code! Don't let your background in any other programming language pollute or bias your approach to learning the new language.

最好的学习方法就是开始编程。选择一个像 Chess 或 Checkers 这样的项目并开始编写代码。买一本像Java How to Program这样的书,通过例子和练习,哦是的....继续写代码!不要让您在任何其他编程语言的背景污染或偏见您学习新语言的方法。

回答by Andrew Lygin

I don't think you should use a special way to learn Java because you know Python. Just start with HelloWorld.java and move on step by step. Your basic skills in programming will help you.

我认为你不应该因为你懂 Python 就用一种特殊的方式来学习 Java。只需从 HelloWorld.java 开始,然后逐步进行。您在编程方面的基本技能将对您有所帮助。

回答by Phil

1) It depends what you would do with an "hireable" language. For instance, if you were interested in programming web applications and distributed/client/server app, Java would be a good choice.

1)这取决于你会用“可雇用”的语言做什么。例如,如果您对编写 Web 应用程序和分布式/客户端/服务器应用程序感兴趣,Java 将是一个不错的选择。

C# is maybe a bit less client / server oriented, and maybe more valuable for small non IT companies and for most retail software companies.

C# 可能不太面向客户端/服务器,对于小型非 IT 公司和大多数零售软件公司来说可能更有价值。

C and C++ are still great languages, but are more "system", embeded and "critical apps" oriented. And they are not suitable to be runned on differents mobile phones.

C 和 C++ 仍然是很棒的语言,但更面向“系统”、嵌入式和“关键应用程序”。并且它们不适合在不同的手机上运行。

2) The best way to learn java, according to me, is firstable to learn the basics, then look for more specialized stuff like J2ME and Android software framework.

2)在我看来,学习java最好的方法是先学习基础,然后寻找更专业的东西,比如J2ME和Android软件框架。

回答by rsp

Same question but from a C++ background yields useful answers for "I know x, how about Java?"

同样的问题,但从 C++ 背景中可以为“我知道 x,Java 怎么样?”提供有用的答案。

回答by Richie

You can work your way through Sun Java tutorials: http://java.sun.com/docs/books/tutorial/

您可以按照自己的方式学习 Sun Java 教程:http: //java.sun.com/docs/books/tutorial/

...richie

...里奇

回答by Victor Olex

I suppose one could ease his/her way into .NET and Java by starting with IronPython and Jython respectively. This will not teach you the new language syntax but open up respective libraries so you can explore what is "out there", learn development tools, build process etc. Syntax is by far the easiest to switch but the know-how and best practices in each language are not.

我想人们可以分别从 IronPython 和 Jython 开始,轻松地进入 .NET 和 Java。这不会教你新的语言语法,但会打开相应的库,这样你就可以探索什么是“外面”,学习开发工具,构建过程等。语法是迄今为止最容易切换的,但是知识和最佳实践每种语言都不是。