Wednesday, December 3, 2014

PEMROGRAMAN " GENERIC " In JAVA

1. Does it Cost Generic ??

Previously we have discussed the collection. For example, using the object list. If we look at the program list can be included various types of data. This is going to be bad when we make the process of data manipulation because certainty the type of data that goes into the collection inconsistent.
To deal with the type of the collection, we can make use of the generic. when the object declaration, we do not need to specify what type of data. for readers who have a basic C ++, then this generic can be implemented by using a template that you know.

Java terbaik 2015


How generic realization in java ??

Java incorporate these generic features since 2004 and part of j2SN 5.0. through these features, can be declared without a specified variable data type. in java we can declare generic with the following symbols:
<E> to elements of a collection
<T> for Type
<K, V> for Key and Value
<N> for members
S, U, V gigunakan for parameters to 2,3,4

If we salh insert generic data type, then we will get a compile-time error instead of when the program starts. Here we declare a generic collection with integer data types. furthermore, we insert some data. at the end we enter the data type string directly and we will get an error if menggunkaan compile IDE that supports real-time.

No comments:

Post a Comment