自2001年以来,了解Java语法变化的最佳方法是什么?

时间:2021-10-01 02:42:12

Duplicate: How do I best catch up with the latest developments in java?

重复:我如何才能最好地了解java的最新发展?

I've been working on a Java codebase that was frozen in time around 2001. As a result I haven't bothered to learn any new Java syntax since then.

我一直在研究一个在2001年左右被冻结的Java代码库。因此,从那以后我就没有费心去学习任何新的Java语法。

Today I saw this code and recognized it as a syntax that must have been introduced in the current decade.

今天我看到了这段代码,并认为它是一种必须在当前十年引入的语法。

private ArrayList<String> colors = new ArrayList<String>();

Which version of Java introduced this angle-bracket notation?

哪个版本的Java引入了这种角括号表示法?

And what would be a good way to learn about other significant changes to the language since 2001? I have a pretty good grasp of everything before that date.

从2001年开始,了解该语言的其他重大变化有什么好方法?在那个日期之前我对所有事情都有很好的把握。

4 个解决方案

#1


Of all recent Java release, Java 5 made the largest and most obvious changes to the language. The summary lists all the new features. In brief:

在最近的Java版本中,Java 5对该语言进行了最大和最明显的更改。摘要列出了所有新功能。简单来说:

  • autoboxing
  • enum, e.g., enum Season { WINTER, SPRING, SUMMER, FALL }
  • enum,例如enum Season {WINTER,SPRING,SUMMER,FALL}

  • Generics, e.g., Collection<String> coll; instead of Collection coll;
  • 泛型,例如Collection coll;而不是Collection coll;

  • ehanced for loop, e.g., for (String str : coll)
  • 增强for循环,例如,用于(String str:coll)

  • varargs, e.g., private void function(Object... arguments);
  • varargs,例如,private void function(Object ... arguments);

  • static import
  • Annotations, e.g., @Override or @Deprecated
  • 注释,例如@Override或@Deprecated

  • String.format like a Java version of printf()
  • String.format像Java版本的printf()

Java 4 introduced a few new features too, primarily assertions.

Java 4也引入了一些新功能,主要是断言。

If you prefer books, you can learn about Java 5 changes from the book Java 5.0 Tiger: A Developer's Notebook. This isn't the most comprehensive book you'll find, but it's a nice and quick introduction to all of the new features of Java 5.

如果您更喜欢书籍,可以从Java 5.0 Tiger:A Developer's Notebook这本书中了解Java 5的变化。这不是您将找到的最全面的书,但它是对Java 5的所有新功能的一个很好的快速介绍。

#2


You're referring to generics, introduced in Java SE 1.5 (or Java 5). Enums got a bit more exciting in the Java 5 release as well as the Java autoboxing and unboxing, annotations and much much more.

您指的是Java SE 1.5(或Java 5)中引入的泛型。 Enum在Java 5发行版以及Java自动装箱和拆箱,注释等方面更令人兴奋。

http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html

http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

Overview: http://java.sun.com/j2se/1.5.0/docs/guide/language/

When you want to get up to speed on Java 6, check out http://java.sun.com/javase/6/features.jsp

如果您想快速掌握Java 6,请查看http://java.sun.com/javase/6/features.jsp

#3


To answer part of your question, Autoboxing was introduced in 1.5

为了回答你的部分问题,Autoboxing在1.5中引入

http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html

#4


The <> notation has to do with generics (like templates). This, like most major changes, have been introduced in Java 5, along with many other language features.

<>表示法与泛型(如模板)有关。与大多数重大更改一样,这已经在Java 5中引入,还有许多其他语言功能。

Here are the updates for Java 5: http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

以下是Java 5的更新:http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

You can find details about specific changes in the Java tutorial.

您可以在Java教程中找到有关特定更改的详细信息。

As far as I know, the changes in later version (e.g., 1.6) are not major: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/beta2.html

据我所知,后期版本(例如1.6)的变化并不重要:http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/beta2.html

#1


Of all recent Java release, Java 5 made the largest and most obvious changes to the language. The summary lists all the new features. In brief:

在最近的Java版本中,Java 5对该语言进行了最大和最明显的更改。摘要列出了所有新功能。简单来说:

  • autoboxing
  • enum, e.g., enum Season { WINTER, SPRING, SUMMER, FALL }
  • enum,例如enum Season {WINTER,SPRING,SUMMER,FALL}

  • Generics, e.g., Collection<String> coll; instead of Collection coll;
  • 泛型,例如Collection coll;而不是Collection coll;

  • ehanced for loop, e.g., for (String str : coll)
  • 增强for循环,例如,用于(String str:coll)

  • varargs, e.g., private void function(Object... arguments);
  • varargs,例如,private void function(Object ... arguments);

  • static import
  • Annotations, e.g., @Override or @Deprecated
  • 注释,例如@Override或@Deprecated

  • String.format like a Java version of printf()
  • String.format像Java版本的printf()

Java 4 introduced a few new features too, primarily assertions.

Java 4也引入了一些新功能,主要是断言。

If you prefer books, you can learn about Java 5 changes from the book Java 5.0 Tiger: A Developer's Notebook. This isn't the most comprehensive book you'll find, but it's a nice and quick introduction to all of the new features of Java 5.

如果您更喜欢书籍,可以从Java 5.0 Tiger:A Developer's Notebook这本书中了解Java 5的变化。这不是您将找到的最全面的书,但它是对Java 5的所有新功能的一个很好的快速介绍。

#2


You're referring to generics, introduced in Java SE 1.5 (or Java 5). Enums got a bit more exciting in the Java 5 release as well as the Java autoboxing and unboxing, annotations and much much more.

您指的是Java SE 1.5(或Java 5)中引入的泛型。 Enum在Java 5发行版以及Java自动装箱和拆箱,注释等方面更令人兴奋。

http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html

http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html

Overview: http://java.sun.com/j2se/1.5.0/docs/guide/language/

When you want to get up to speed on Java 6, check out http://java.sun.com/javase/6/features.jsp

如果您想快速掌握Java 6,请查看http://java.sun.com/javase/6/features.jsp

#3


To answer part of your question, Autoboxing was introduced in 1.5

为了回答你的部分问题,Autoboxing在1.5中引入

http://java.sun.com/j2se/1.5.0/docs/guide/language/autoboxing.html

#4


The <> notation has to do with generics (like templates). This, like most major changes, have been introduced in Java 5, along with many other language features.

<>表示法与泛型(如模板)有关。与大多数重大更改一样,这已经在Java 5中引入,还有许多其他语言功能。

Here are the updates for Java 5: http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

以下是Java 5的更新:http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

You can find details about specific changes in the Java tutorial.

您可以在Java教程中找到有关特定更改的详细信息。

As far as I know, the changes in later version (e.g., 1.6) are not major: http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/beta2.html

据我所知,后期版本(例如1.6)的变化并不重要:http://java.sun.com/developer/technicalArticles/J2SE/Desktop/javase6/beta2.html