Tumgik
captainragingcoffee · 4 years
Text
Lacking features in Java Generics?
For me, in the current version of Java today, so far there are no more lacking featured regarding java generics. The main feature lacking in java generics in 2015 is the lackness of Reified Generics, but with Kotlin’s Reified Generics, normal Java generics, the generic parameter is only known at compile time, and is erased from the runtime. Kotlin’s reified generics allow you to pretend that the generic is still there at runtime, by effectively swapping out the placeholder <T> with the known type when it is actually used.
0 notes
captainragingcoffee · 4 years
Text
Importance of Java Generics!
Generics are one of the most controversial Java language features. Generics allows a type or method to operate on objects of various types while providing compile-time type safety, making Java a fully statically typed language. Here are five important things to know about Generics
1 .Generics are implemented using type erasure In Java a class or an interface can be declared to define one or more type parameters and those type parameters should be provided at the time of object construction.
2. Generics does not support sub-typing Generics does not support sub-typing which means that List is not considered to be a sub-type of List, where S is a subtype of T.
3. You can't create Generic Arrays  Arrays uses this information at runtime to check the type of the object it contains and will throw ArrayStoreException if the type does not match. But with Generics type information gets erased and the array store check will succeed in cases where it should fail.
4. Use of wildcards with extends or super to increase API flexibility There are times that you need to work not only with T but also with sub types of T. For example, the addAll method in the Collection interface which adds all the elements in the specified collection to the collection on which it is called.
5. Use of Multiple Bounds Multiple bounds is one of the generics features which most developer do not know. It allows a type variable or wildcard to have multiple bounds. For example, if you to define constraint such as that the type should be a Number and it should implement Comparable.
Problems solved by Java Generics
Prior to java 1.5, there was no way to specify types for objects when we need to use them in collections. Java is supposed to be a typed language and not being able to specify the types of its objects where necesary completely defeats the purpose. Developers find themselves working with a lot of collections and not guaranteeing the type objects contained in their collections exposed their code to potential bugs. 
0 notes
captainragingcoffee · 4 years
Photo
Tumblr media Tumblr media
Java Generic methods and generic classes enable programmers to specify with a single method declaration (ex. (public int max(int x, int y)), whereas the method ‘max’ is declared, a set of related methods, or with a single method declaration, a set of related types, respectively. Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time. Using Java Generic concept, we might write a generic method for sorting an array of objects, then invoke the generic method with Integer arrays, Double arrays, String arrays and so on, to sort the array elements
Primitive data types cannot be used as an argument for generic type variables, for object is a superclass of all objects, since primitive data types does not inherit from the superclass object, therefore we cannot use it as a generic type.
0 notes
captainragingcoffee · 5 years
Photo
Tumblr media Tumblr media Tumblr media Tumblr media
Upon questioning how prepared the barangay whenever there is disaster, chairperson ‘papa’ told us that, they are well prepared for the aftermath of the disaster, also, they are prepared in terms of having precautionary protocols such as evacuating the residents and give them relief goods. Inside their stock room, a roomful of equipment welcomed us as I take a look at their equipment.
0 notes
captainragingcoffee · 5 years
Photo
Tumblr media Tumblr media Tumblr media Tumblr media
One of the major problems of Brgy.Rosario is flash floods. Once the rain falls hard, the residents automatically expects the roads to be submerged in water due to poor canal management. Also, another challenge for them is the proper waste management which makes the canals clogged.
0 notes
captainragingcoffee · 5 years
Photo
Tumblr media Tumblr media Tumblr media
A trip to my home town, Santiago City. I went to a quick visit to Brgy. Rosario in order to check and ask the chairperson about how they handled the barangay whenever there are disasters caused by calamities such as typhoons.
1 note · View note