从 C# 迁移到 Java 的技巧?

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

Tips for moving from C# to Java?

c#java

提问by Peter Mounce

So I'm going to a job interview next week at a Java place, and would like to not come across as clueless. I'm a pretty confident C#/.NET developer and am (clearly!) willing to consider jumping ship to Java - I'd like links to resources people would recommend for doing this. I'm interested in answers to questions like:

所以我下周要去一个 Java 的地方参加工作面试,我不想让人觉得自己一无所知。我是一个非常自信的 C#/.NET 开发人员,并且(显然!)愿意考虑跳槽到 Java - 我想要链接到人们会推荐这样做的资源。我对以下问题的答案感兴趣:

  • Any guides that are a rough equivalent to Justin Etheridge's Ruby for C# developers? That was really useful when I decided I wanted to learn Ruby's rake (and thus at least a little Ruby). There seem to be more pages for people going the other way, though...
  • Which IDE to use? I've actually already bought my own IntelliJ because I love its HTML/CSS/JS, but haven't touched its actual raison d'etre of, well, "that Java stuff". I suspect the place I'm going to uses Eclipse, however. So - recommended resources to get up and running on a Mac or Windows (I'm not fussy)?
  • It's probably going to be a TDD coding interview; I guess JUnit is the de facto choice to learn a little about here?
  • 任何与Justin Etheridge 为 C# 开发人员编写的 Ruby大致相当的指南?当我决定要学习 Ruby 的 rake(因此至少要学习一点 Ruby)时,这真的很有用。不过,似乎有更多页面可供人们选择相反的方式……
  • 使用哪个IDE?我实际上已经购买了我自己的 IntelliJ,因为我喜欢它的 HTML/CSS/JS,但还没有触及它的实际存在理由,好吧,“那些 Java 的东西”。但是,我怀疑我要使用 Eclipse 的地方。那么 - 在 Mac 或 Windows 上启动和运行的推荐资源(我不挑剔)?
  • 这可能是一次 TDD 编码面试;我猜 JUnit 是在这里学习一点的事实上的选择?

Thanks in advance.

提前致谢。

采纳答案by Richard Walton

Take a look at this linkwhich details many of the differences between the two languages.

查看此链接,其中详细介绍了两种语言之间的许多差异。

As for IDE many people like Eclipse or Netbeans (My favorite) - Both are free. As you already own IntelliJ you could try that.

至于 IDE,很多人喜欢 Eclipse 或 Netbeans(我最喜欢的)——两者都是免费的。由于您已经拥有 IntelliJ,您可以尝试一下。

FYO some of the main differences are:

FYO的一些主要区别是:

  • Lack of properties / auto properties
  • No 'event' type (Different way of dealing with events)
  • foreach loop syntax
  • 'Generics' implementation
  • Checked exceptions
  • 缺少属性/自动属性
  • 没有“事件”类型(处理事件的不同方式)
  • foreach 循环语法
  • “泛型”实现
  • 检查异常

and probably many more :)

可能还有更多:)

回答by Elie

As you mentioned, for an IDE you should consider Eclipse, which is free and a decent IDE for basic development. If you're going to be working with Java EE, however, it may not be sufficient, but it will help you learn the basics quickly.

正如您提到的,对于 IDE,您应该考虑 Eclipse,它是免费的,是用于基本开发的不错的 IDE。但是,如果您打算使用 Java EE,这可能还不够,但它会帮助您快速学习基础知识。

There are many books that cover basic syntax and programming style, and any, assuming that you are a good C# developer, will probably be enough to get you going. I don't know of any off-hand of the type you mentioned.

有很多涵盖基本语法和编程风格的书籍,假设您是一名优秀的 C# 开发人员,任何书籍都可能足以让您入门。我不知道你提到的那种副手。

I recently did the transition in the reverse, going from Java to C#. I found that by rewriting an existing application in the new language made it much easier than I had thought it would be.

我最近做了相反的转换,从 Java 到 C#。我发现用新语言重写现有的应用程序比我想象的要容易得多。

回答by Kredns

Netbeans is the best (and most like visual studio) IDE out for java developers. You will love it if you have enough RAM for it.

Netbeans 是 Java 开发人员最好的(也是最像 Visual Studio 的)IDE。如果你有足够的内存,你会喜欢它的。

回答by Adeel Ansari

IDE

集成开发环境

You got IntelliJ. Believe me its the best. I used it for two years, then had to switch to some free thingy. I tried Eclipse, it was a pain, no offense just telling you my experience. Now, working with Netbeans, and I am quite happy, but still miss IntelliJ once in a day.

你有 IntelliJ。相信我这是最好的。我用了两年,然后不得不改用一些免费的东西。我试过 Eclipse,这很痛苦,只是告诉你我的经历,没有冒犯的意思。现在,与 Netbeans 一起工作,我很高兴,但仍然每天都会错过一次 IntelliJ。

TDD

TDD

Yes, you are very much right about JUnit. After enough understanding, its good to look at other specialize libraries like HtmlUnit, DBUnit. Further, a code coverage tool like Cobertura, or Emma. As you must go with IntelliJ, you will probably like to check out Emma, as its having a good integration with the IDEA.

是的,您对 JUnit 的看法非常正确。了解足够多之后,再看看其他的专业库,比如 HtmlUnit、DBUnit。此外,还有像 Cobertura 或 Emma 这样的代码覆盖率工具。由于您必须使用 IntelliJ,您可能会喜欢查看 Emma,因为它与 IDEA 有很好的集成。

Transition

过渡

I don't think you will have a hard time in the transition. IMO, reading the docs and the specs will get you going. May be you can go for some books down the road, but as far as core Java is concern, reading API docs and specs will be a good start. You can make use of a SO to ask question. I have seen many questions like "C# equivalent in Java ..".

我不认为你会在过渡中遇到困难。IMO,阅读文档和规范会让你前进。也许你可以在路上读一些书,但就核心 Java 而言,阅读 API 文档和规范将是一个好的开始。您可以使用 SO 来提问。我见过很多问题,比如“Java 中的 C# 等价物......”。

回答by Fortyrunner

If you have a week - try and write as much Java code as you can.

如果您有一周的时间 - 尝试尽可能多地编写 Java 代码。

I found it very easy to go from Java to C# and it should be the same the other way.

我发现从 Java 到 C# 非常容易,反过来也应该一样。

Pick up a copy of Effective Java and read it through - it's very good indeed.

拿起一份 Effective Java 并通读一遍——它确实非常好。

回答by Eugene Yokota

I think the biggest difference is the community and environment surrounding the two platforms. In .NET world, Microsoft makes big decisions and rolls out feature sets. On the other hand, there are many third-party libraries in the Java world that almost supplements the platform, and you are supposed to know them if you are into certain kind of development. See Most useful free Java libraries.

我认为最大的区别是围绕两个平台的社区和环境。在 .NET 世界中,Microsoft 做出重大决策并推出功能集。另一方面,Java 世界中有许多第三方库几乎是对平台的补充,如果您从事某种开发,应该知道它们。请参阅最有用的免费 Java 库

回答by Alan

Since you've only got a week, I would echo the recommendation to focus on the sort of things pointed out by Effective Java.

由于您只有一周的时间,因此我同意建议将重点放在Effective Java指出的那种事情上。

Know the Collections API. When I interview folks, it's one way I weed out folks. Especially know the difference between equals(), hashCode()and compareTo(), and what it takes to implement them correctly.

了解集合 API。当我采访人们时,这是我淘汰人们的一种方式。尤其要知道equals(),hashCode()和之间的区别,以及compareTo()正确实现它们需要什么。

Know how to handle exceptions in Java, and how it interacts with standard EJB transactions.

了解如何在 Java 中处理异常,以及它如何与标准 EJB 事务交互。

If you're fortunate to land the job, I would spend some time getting to know the J2EE landscape, which is quite vast. These days, I would consider fundamentals of J2EE to be EJBs, MDBs, servlets and JPA.

如果您有幸获得这份工作,我会花一些时间来了解 J2EE 领域,它非常广阔。现在,我认为 J2EE 的基础是 EJB、MDB、servlet 和 JPA。

I wouldn't worry so much about the IDE, or the xUnit API. Those things are trivial for any decent developer with experience.

我不会太担心 IDE 或 xUnit API。对于任何有经验的体面开发人员来说,这些事情都是微不足道的。