JAVA EXAMPLE PROGRAMS

JAVA EXAMPLE PROGRAMS

Publish Your Article Here

Java Generics

Generics were added by JDK 5. Most of the algorithms are logically same irrespective of the type of data they are being applied to. By using generics you can define an algorithm once, and you can apply it on any kind of datatype without any additional effort.

At very high level, generics are nothing but parameterized types. Generics helps us to create a single class, which can be useful to operate on multiple data types. A class, interface or a method that operates on a parameterized type is called generics class, interface or method. Generics adds type safty. Remember that generics only works on objects, not primitive types. Here you can find many examples to create generic classes, generic methods, and generic interfaces.

Java Generics Sample Code Examples

  1. Write a simple generics class example.
  2. Write a simple generics class example with two type parameters.
  3. How implement bounded types (extend superclass) with generics?
  4. How implement bounded types (implements an interface) with generics?
  5. What is generics wildcard arguments? Give an example.
Knowledge Centre
Domain Naming Service(DNS)
It is very difficult to remember a set of numbers (IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www.java2novice.com implies com is the domain name reserved for US commercial sites, java2novice is the name of the company and www is the name of the specific computer, which is java2novice's server.
Famous Quotations
Good judgment comes from experience, and experience comes from bad judgment.
-- Barry LePatner

About Author

I'm Nataraja Gootooru, programmer by profession and passionate about technologies. All examples given here are as simple as possible to help beginners. The source code is compiled and tested in my dev environment.

If you come across any mistakes or bugs, please email me to [email protected].

Most Visited Pages

Other Interesting Sites

Reference: Java™ Platform Standard Ed. 7 - API Specification | Java™ Platform Standard Ed. 8 - API Specification | Java is registered trademark of Oracle.
Privacy Policy | Copyright © 2022 by Nataraja Gootooru. All Rights Reserved.