作者彙整: Rafael Chinelato Del Nero

Java Challengers #4: Comparing Java objects with equals() and hashcode()

In this Java Challenger you’ll learn how equals() and hashcode() combine to make object comparisons efficient and easy in your Java programs. Simply put, these methods work together to verify if two objects have the same values.  

Without equals() and hashcode() we would have to create very large “if” comparisons, comparing every field from an object. This would make code really confusing and hard to read. Together, these two methods help us create more flexible and cohesive code.

閱讀全文

分類: IT 資訊科技(信息技术), java教學網站, 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Challengers #4: Comparing Java objects with equals() and hashcode()〉中留言功能已關閉

Java Challengers #7: Debugging Java inheritance

Inheritance and composition are two programming techniques developers use to establish relationships between classes and objects. Whereas inheritance derives one class from another, composition defines a class as the sum of its parts.

Classes and objects created through inheritance are tightly coupled because changing the parent or superclass in an inheritance relationship risks breaking your code. Classes and objects created through composition are loosely coupled, meaning that you can more easily change the component parts without breaking your code.

Because loosely coupled code offers more flexibility, many developers have learned that composition is a better technique than inheritance, but the truth is more complex. Choosing a programming tool is similar to choosing the correct kitchen tool: You wouldn’t use a butter knife to cut vegetables, and in the same way you shouldn’t choose composition for every programming scenario. 

To read this article in full, please click here

閱讀全文

分類: Android News 安卓新聞, IT 資訊科技(信息技术), 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Challengers #7: Debugging Java inheritance〉中留言功能已關閉

Java Challengers #6: Thread behavior in the JVM

Threading refers to the practice of executing programming processes concurrently to improve application performance. While it’s not that common to work with threads directly in business applications, they’re used all the time in Java frameworks.As a… 閱讀全文

分類: Android News 安卓新聞, IT 資訊科技(信息技术), 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Challengers #6: Thread behavior in the JVM〉中留言功能已關閉

Java Challengers #6: Thread behavior in the JVM

Threading refers to the practice of executing programming processes concurrently to improve application performance. While it’s not that common to work with threads directly in business applications, they’re used all the time in Java frameworks.As a… 閱讀全文

分類: Android News 安卓新聞, IT 資訊科技(信息技术), 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Challengers #6: Thread behavior in the JVM〉中留言功能已關閉

Java Challengers #5: Sorting with Comparable and Comparator in Java

Programmers frequently need to sort elements from a database into a collection, array, or map. In Java, we can implement whatever sorting algorithm we want with any type. Using the Comparable interface and compareTo() method, we can sort using alpha… 閱讀全文

分類: Android News 安卓新聞, IT 資訊科技(信息技术), 熱門新聞 | 標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , | 在〈Java Challengers #5: Sorting with Comparable and Comparator in Java〉中留言功能已關閉