• 27 April

    Abstraction in Java

    1. Introduction Abstraction is a concept of exposing only essential details and hiding implementation details. It is one of the essential OOPs concept apart from encapsulation, inheritance and polymorphism. Abstraction retains only information which is most relevant for the specific purpose. For example: ArrayList stores objects sequentially as list, and you can use the add() method […]

  • 27 April

    Interface in java

    In previous post, we have seen abstract class in java which provides partial abstraction. Interface is one of the core part of java and is used to achieve full abstraction. Interface is generally used to provide contract for class to implement. Interface do not have implementation of any method.A class implements an interface, thereby inheriting […]

  • 27 April

    Abstract class in java

    An abstract class is the class which is declared abstract and can have abstract or non abstract methods. An abstract class can not be instantiated. It can be extended by subclass to implement abstract methods and either use or override concrete methods. Abstract method in java Abstract method is the method which do not have […]

  • Java ReentrantReadWriteLock Example
    27 April

    Java ReentrantReadWriteLock Example

    In this tutorial, we will see ReentrantReadWriteLock Example. ReentrantReadWriteLock supports semantics of ReentrantLock and also ReadWriteLock. ReadWriteLock has two locks, one for read and one for write. Request for read lock from multiple threads can be acquired if there is no write request. If there is a write request, no other thread will be able to […]

  • 27 April

    Switch case in java

    Switch case in java is alternative to if else if ladder. It is used to execute statements based on some conditions. Syntax of Switch case in java [crayon-66391dc3ef32c710979843/] Let’s understand it with the help of simple example. We are going to print weekday based on integer. 0 represents Sunday, 1 represents Monday and so on.. […]

  • 27 April

    if else statement in java

    If else statements in java are used to test some conditions. It evaluates a condition to be true or false. There are three types of if statements. If statement If else statement If else if ladder statement Simple If statement [crayon-66391dc3efcac147876271/] For example: [crayon-66391dc3efcb4773449472/] Output: Price is greater than 10 You can write single line followed […]

  • 27 April

    Comments in java code

    Comments are the essential part of code. If you write good comments, it will be easier for others to understand the code. Comments are ignored by the compiler when it compiles the program. There are three types of comments in java code. Single line comments Multi-line comments Java doc comments Single line comments: These are […]

  • 27 April

    Do While Loop in Java with Example

    1. Introduction In programming, controlling the flow of execution is essential for building functional and efficient applications. Java provides several control flow statements, and among these, the do-while loop offers a unique way to execute a block of code at least once and then repeat the execution based on a given condition. 2. The Syntax […]

  • 13 April

    Break Statement in Java

    1. Introduction The break keyword in Java is primarily used in two contexts: within loops (for, while, and do-while) and in switch statements. Its main purpose is to terminate the loop or switch statement and transfer control to the statement immediately following the loop or switch. 2. Syntax The syntax of the break statement is […]