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 …
Java
What is transient keyword in Java?
Java Transient Keyword This article explains about the transient variable and when it will be used in the Java programming. Another important fact is that, this question is most frequently asked in the Java interviews for checking the basic knowledge of a programmer. Another point is that the Java transient keyword is not frequently used …
Ordering Queue Using Comparator Interface and PriorityQueue
The basic use of Queue class is to provide a data structure which allows storing objects in a First in First out(FIFO) format. But sometimes one wants to maintain the ordering, based on some other metric. This is exactly the purpose of PriorityQueue, another Queue implementation. You provide it a Comparator, and it does the …
Introduction to Java Module System in Java 7.0
This article explains the new Java Module System that will be included in the Java 7.0 release. Modules are new to the java language and they provide a standard for developing and deploying applications. The article will explain the various sub components that are available as part of the Java Module System’s architecture. The various …
JDBC connection in JDeveloper with MySQL database
The Java Database Connectivity (JDBC) API is used to access a SQL database from a Java application. JDBC also supports tabular data sources, such as a spreadsheet. Oracle JDeveloper is a free Integrated Development Environment (IDE) for modeling, developing, debugging, optimizing, and deploying Java applications. JDeveloper 10g is used to develop J2EE applications comprising the JSPs, …
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, …
Hiding and Overriding Methods In Java
Now in section Inheritance mainly in Hiding And Overriding Methods can we predict the output of the following program? also read: Java Tutorials Java EE Tutorials Design Patterns Tutorials Java File IO Tutorials It Prints: Here the overriding methods getX and getY in class RealPoint have the same return types as the methods of class …