(Java programming Example for Beginners) Java Vector In this tutorial, we will learn about the Vector class and how to use it. We will also learn how it is different from the ArrayList class, and why we should use array lists instead. The Vector class is an implementation of the List interface that allows us to create resizable-arrays similar …
(Java programming Example for Beginners) Java List In this tutorial, we will learn about the List interface in Java and its methods. In Java, the List interface is an ordered collection that allows us to store and access elements sequentially. It extends the Collection interface. Classes that Implement List Since List is an interface, we cannot create objects from it. In …
(Java programming Example for Beginners) Java Collection Interface In this tutorial, we will learn about the Java Collection interface and its subinterfaces. The Collection interface is the root interface of the Java collections framework. There is no direct implementation of this interface. However, it is implemented through its subinterfaces like List, Set, and Queue. For example, the ArrayList class implements the List interface which …
(Java programming Example for Beginners) Java Collections Framework In this tutorial, we will learn about different interfaces of the Java collections framework. The Java collections framework provides a set of interfaces and classes to implement various data structures and algorithms. For example, the LinkedList class of the collections framework provides the implementation of the doubly-linked list data structure. Interfaces …
(Java programming Example for Beginners) Java Assertions In this tutorial, we will learn about the Java assert statement (Java assertions) with the help of examples. Assertions in Java help to detect bugs by testing code we assume to be true. An assertion is made using the assert keyword. Its syntax is: assert condition; Here, condition is a boolean expression that …
(Java programming Example for Beginners) Java Annotation Types In this tutorial, we will learn about different types of Java annotation with the help of examples. Java annotations are metadata (data about data) for our program source code. There are several predefined annotations provided by the Java SE. Moreover, we can also create custom annotations as …
(Java programming Example for Beginners) Java Annotations In this tutorial, we will learn what annotations are, different Java annotations and how to use them with the help of examples. Java annotations are metadata (data about data) for our program source code. They provide additional information about the program to the compiler but are not part …
(Java programming Example for Beginners) Java try-with-resources In this tutorial, we will learn about the try-with-resources statement to close resources automatically. The try-with-resources statement automatically closes all the resources at the end of the statement. A resource is an object to be closed at the end of the program. Its syntax is: try (resource declaration) { // …
(Java programming Example for Beginners) Java throw and throws In this tutorial, we will learn to use throw and throws keyword for exception handling with the help of examples. In Java, exceptions can be categorized into two types: Unchecked Exceptions: They are not checked at compile-time but at run-time.For example: ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException, exceptions under Error class, etc. Checked Exceptions: They are …
(Java programming Example for Beginners) Java Exceptions In this tutorial, we will learn about exceptions in Java. We will cover errors, exceptions and different types of exceptions in Java. An exception is an unexpected event that occurs during program execution. It affects the flow of the program instructions which can cause the program to terminate …