Suppose you want to create a list object in Java and populate it with some default elements, how would you go about coding it? One will pursue one of the following approaches: (If you have any other approach feel free to share them via the comments and we will update the post accordingly). In the …
Java 5.0
Introduction to Java Agents
In this article we will discuss about Java Agents. Java Agents are software components that provide instrumentation capabilities to an application. In the context of agents, instrumentation provides the capability of re-defining the content of class that is loaded at run-time. We will discuss this in more detail in the further sections. Download Source Code: …
Java 5.0
Java 5.0 Java Platform, Standard Edition (also known as Java 2 Platform) lets you develop and deploy Java applications on desktops and servers, as well as today’s demanding Embedded and Real-Time environments. Java SE includes classes that support the development of Java Web Services and provides the foundation for Java Platform, Enterprise Edition (Java EE). …
Adding methods to an Enum
Enums introduced in Java 5.0 are just compiled java classes with some extra behavior. So you can basically do whatever you can in a normal java class inside an enum as well. That includes adding methods , class level variables and constructors to an enum. Adding methods to an enum works just like adding methods …
Mixing Generics And Non-Generics Code
If we are work on code that uses generics that is fine and what will happen if we want to mix both generic and non generic code. Consider below Animal class also read: New Features in Java 5.0 Generics in Java 5.0 Annotations in Java 5.0 if we create the list like below will it …
How to use ? extends in Generics?
In generics as we know we can not assign subclass generic type to super class generic type, for example will not compile even though Dog IS-AN Animal. the reason for this is already explained in generics basics section. How can we solve this particular problem????? we can solve this problem by using wildcard in generics, …
Precise rounding of decimals using Rounding Mode Enumeration
The Rounding Mode Enum in java.math package is used to perform precise rounding of decimal values. It was introduced in Java 5.0. This Enum provides various constants each of which is used for different modes of rounding. The decimal value would be rounded off to the number of decimal places based on the scale that …
Generics in Java 5.0
1) Introduction The feature of Generics in Java allows Applications to create classes and objects that can operate on any defined types. Programmers can now make use of the Generics feature for a much better code. There is no need for un-necessary casting when dealing with Objects in a Collection. This article provides a detailed …