Generics is the mechanism of creating a class or method that works for any type of data. Here we covered the complete tutorial along with suitable examples and sample programs, Examples. Note: Generics work with objects (Integer, Double, String, etc) only. They cannot be used with primitive type data (int, double, etc). [crayon-673f07ff28941491940049/] Output: [crayon-673f07ff28947801096296/] In the above example, class ...
Read More »Java Tutorials
Java Constructor Chaining – Types & Example | Tutorials
Java Constructor Chaining – Calling one constructor from another constructor is generally referred to as constructor chaining. This can be achieved in two ways. this() super() in some cases we use only this(), in some other cases, we use only super(). Sometimes we use both (but not directly). Normal Java constructor calling (without chaining) When we create an object, its ...
Read More »Exception Handling In Java – Tutorial & Examples
What is Exception Handling In Java – When we work with a program we come up with different kinds of errors like syntactical errors, logical errors, runtime errors, etc. let us try to differentiate these errors with a simple program. Example Program To Differentiate the Errors: [crayon-673f07ff29050046552970/] The above program will not cross the compilation stage because there is a ...
Read More »Multilevel Inheritance In Java – Tutorial & Examples
What is Multilevel Inheritance In Java? In Java (and in other object-oriented languages) a class can get features from another class. This mechanism is known as inheritance. When multiple classes are involved and their parent-child relation is formed in a chained way then such formation is known as multi-level inheritance. In multilevel inheritance, a parent a class has a maximum ...
Read More »Java Convert Double To Long – Examples
Java convert double to Long – We have different ways to convert a double value to a long value or from long to double. Apart from the given program, you can check out the list of over 500+ Java programs with sample examples and outputs. Methods we used to convert double to long/ long to double: Simple type conversion round() ...
Read More »List Of Difference Between Abstract Class And Interface | Tutorial
Differences between Abstarct class and Interface complete tutorial with suitable examples and sample outputs. In case if you need more information about the difference between Abstract class and Interface leave a comment here. An abstract class can have concrete methods, but an interface cannot have. Example 1: [crayon-673f07ff2952b839493558/] [crayon-673f07ff2952e615469395/] Example 2: An abstract class can consist both abstract methods and ...
Read More »Constructors In Java – Types & Examples | JavaTutorials
A constructor is a special method that is invoked when a new object is created. If we want to perform any one-time activities on an object at the time of its creation, then the constructor is the right place. Generally, the initialization of instance variables are done in the constructor. The purpose of a constructor is not limited to initialization. ...
Read More »Multithreading In Java – Tutorial & Examples | JavaTutorials
Multithreading in Java, is the mechanism of executing different parts of a program simultaneously. Suppose, in a normal program, we are in one method and calling another method then the control goes to the called method, executes the statements in that method and comes back to calling the method. As long as the control executes the method, the statements after ...
Read More »Java BigInteger Class – Tutorial & Examples | JavaTutorials
Whats is Java BigInteger? The class BigInteger is in the package java.math In Java, we have 4 data types to deal with integer type data. Those are byte, short, int and long. With byte, we can store numbers up to 127. With short, we can store numbers up to 32767. With int, we can store numbers up to 2147483647. With ...
Read More »Convert String To int Java – Examples | Java
How to Convert String to int in Java – The following article will let you know the complete information about string to int java, in case if you have any doubts do let me know. We have different ways to convert a String to int in Java Integer.parseInt() Integer.valueOf() Integer.parseUnsignedInt() Our own logic equivalent to – Integer.parseInt() Integer.decode() Integer() constructor ...
Read More »