Java Static keyword

Static is a keyword in Java used to represent the class members. It can be used with variables, methods, initializer blocks, and nested classes. Types of class members: Static data members. Static initializer block. Static method. Static nested class. 1. Static data members: Data members declared with static keywords are known as static data members. … Read more

Java Package class

Package class provides information about a package like a package name, implementation title, etc. Java Package class Example package com.w3schools; public class PackageClassTest { public static void main(String args[]) { Package package1 = Package.getPackage(“java.lang”); System.out.println(“package name: ” + package1.getName()); System.out.println(“Specification Title: ” + package1.getSpecificationTitle()); System.out.println(“Specification Vendor: ” + package1.getSpecificationVendor()); System.out.println(“Specification Version: ” + package1.getSpecificationVersion()); System.out.println(“Implementaion … Read more

Java Static import

Static import is a feature that provides the facility to access static members of a class directly without using a class name. Java Static import Example package com.w3schools.display; public class Display { public static void displayText(String text){ System.out.println(text); } } package test; import static com.w3schools.display.Display.*; public class Test { public static void main(String args[]){ displayText(“Hello … Read more

Java Access Modifier

Access modifiers Access modifiers are keywords used for defining the accessibility of classes, methods, and data members. Types of access modifiers. Private. Default Protected Public Private: Data members, methods, and constructors that are declared with private access modifiers can be accessed into that class only. package com.w3schools; class Student { //private members of the class … Read more

Package in java

The package is a namespace that is used to group logically related classes and interfaces. Advantages/Benefits of the package in Java A package provides a unique namespace. A package provides access protection. A Package provides a grouping of logically related classes and interfaces that are easy to maintain. How to create a package? A package … Read more

Java Constructor

Constructor A constructor is a special member (method) of a class that is used to initialize the state of an object. It provides the values to the data members at the time of object creation which is why it is known as a constructor. Characteristics of the constructor A constructor has the same name as … Read more

Java Interface

The dictionary meaning of interface is “A point where two systems, subjects, organizations, etc., meet and interact.” Interface in the real world You can see a number of interface examples. Let us take the example of a TV. You press the change channel button of the TV remote and the channel is changed. Here remote … Read more