Polymorphism « Class « Java Articles

Home
Java Articles
1.Build Deploy
2.Class
3.Core Library
4.Data Types
5.Database JDBC
6.Design
7.Development
8.File Input Output
9.Graphics Desktop
10.J2EE Enterprise
11.J2ME Wireless
12.JVM
13.Language
14.Library Product
15.Network
16.Security
17.SOA Web Services
18.Test
19.Web Development
20.XML
Java Articles » Class » Polymorphism 

1. Behold the power of parametric polymorphism    javaworld.com

You could potentially obtain more precise type checking, but only by sacrificing polymorphism and duplicating code. You could, for instance, create a special List class (with corresponding Cons and Empty subclasses, as well as a special Visitor interface) for each class of element you store in a List. In the example above, you would create an IntegerList class whose elements are all Integers. But if you wanted to store, say, Booleans in some other place in the program, you would have to create a BooleanList class.

2. Java Tip 30: Polymorphism and Java    javaworld.com

In my previous Java Tip, I discussed how you can get your compiler to check that constant values are valid. As I mentioned in that tip, although the use of these constructs makes code more readable, it can lead to a series of if/else if clauses in the client code. This new Java Tip also incorporates typesafe constants and a technique that can be used to remove the aforementioned condition checking.

3. Reveal the magic behind subtype polymorphism    javaworld.com

Polymorphism in Java is invariably subtype polymorphism. Closely examining the mechanisms that generate that variety of polymorphic behavior requires that we discard our usual implementation concerns and think in terms of type. This article investigates a type-oriented perspective of objects, and how that perspective separates what behavior an object can express from how the object actually expresses that behavior. By freeing our concept of polymorphism from the implementation hierarchy, we also discover how Java interfaces facilitate polymorphic behavior across groups of objects that share no implementation code at all.

4. Polymorphism in its purest form    javaworld.com

This is polymorphism in its purest form. By creating different implementations of DateFormat but treating each of them as the superclass, we have a type that displays many different behaviors. By taking such an approach, we can program very generically.

5. Objects and Java Seminar: Polymorphism and Interfaces    artima.com

In a class named Dictionary (in a file named Dictionary.java), create a class (static) variable named WORD_COUNT of type long. Make WORD_COUNT public and final. Initialize WORD_COUNT in a static initializer to the value 1234567. (A static initializer is just an "= " after the declaration of the static variable and before the semicolon. Create a static initialization block inside Dictionary that prints the value of WORD_COUNT out to the standard output with this string message: "Dictionary: WORD_COUNT == ".

6. Polymorphism and Interfaces: Chapter 7 of Objects and Java    artima.com

The creation of if-else constructs like the one shown above are possible in Java because of the instanceof operator, which allows you to check whether an object is an instance of a certain class. Here the instanceof operator is being abused, and the code should be reorganized to use polymorphism. The instanceof operator, and the situations in which it should be used, will be discussed later in this chapter.

7. Prefer polymorphism over instanceof and downcasting    artima.com

Use getPlace() as an example of instanceof. Use perhaps values() and keySet() of LinkMap as example of polymorphism and dynamic binding.

8. The Essence of OOP Using Java, Polymorphism and Interfaces, Part 1    developer.com

Previous article: The Essence of OOP Using Java, Polymorphism and the Object Class Next article: The Essence of OOP using Java, Polymorphism and Interfaces, Part 2

9. The Essence of OOP using Java, Polymorphism and Interfaces, Part 2    developer.com

The first lesson in the group was entitled The Essence of OOP Using Java, Objects, and Encapsulation. That lesson, and each of the lessons following that one, has provided explanations of certain aspects of the essence of Object-Oriented Programming using Java. The previous lesson was entitled The Essence of OOP using Java, Polymorphism and Interfaces, Part 1.

10. The Essence of OOP using Java, Runtime Polymorphism through Inheritance    developer.com

As you gain more experience with Java, you will learn that much of the power of OOP using Java is centered on runtime polymorphism using class inheritance, interfaces, and method overriding. (The use of interfaces for polymorphism will be discussed in a subsequent lesson.)

11. The Essence of OOP Using Java, Polymorphism Based on Overloaded Methods    developer.com

Previous article: The Essence of OOP Using Java, Inheritance, Part 2 Next article: The Essence of OOP using Java, Polymorphism, Type Conversion, Casting, Etc.

12. The Essence of OOP Using Java, Polymorphism and the Object Class    developer.com

The first lesson in the group was entitled The Essence of OOP Using Java, Objects, and Encapsulation. That lesson, and each of the lessons following that one, has provided explanations of certain aspects of the essence of Object-Oriented Programming using Java. The previous lesson was entitled The Essence of OOP using Java, Runtime Polymorphism through Inheritance.

13. The Essence of OOP using Java, Polymorphism, Type Conversion, Casting, Etc.    developer.com

The first lesson in the group was entitled The Essence of OOP Using Java, Objects, and Encapsulation. That lesson, and each of the lessons following that one, has provided explanations of certain aspects of the essence of Object-Oriented Programming using Java. The previous lesson was entitled The Essence of OOP using Java, Polymorphism Based on Overloaded Methods.

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.