package com.coderzpy.code;
class Simple{
public static void main(String args[]){
System.out.println("Hello subpackage");
}
}
To Compile: javac -d . Simple.java
To Run: java com.coderzpy.code.Simple
Output
Hello subpackage
Sub packages are used to further categorize and divide a package. It’s comparable to creating a subfolder within a folder to further categorize it so you can better organize your stuff and make it easier to access. A package may contain several sub-packages.
The Pattern class of the java.util.regex subpackage is demonstrated in the sample below. Regular expression classes and interfaces are contained in this sub package.
import java.util.regex.Pattern;
// To imports all classes of java.util.regex subpackage.
// import java.util.regex.*;
class Pattern_program {
public static void main(String args[]) {
// Checks if the given string contains only alphabets
System.out.println(Pattern.matches("[a-zA-Z]*", "JavaCoding"));
System.out.println(Pattern.matches("[a-zA-Z]*", "JavaCoding2Coderzpy"));
// Checks if the given string contains only numbers
System.out.println(Pattern.matches("[0-9]*", "123456"));
System.out.println(Pattern.matches("[0-9]*", "123XZY6"));
}
}
true
false
true
false
Java 5’s static import feature allows java programmers to directly access any static member of a class. It’s not necessary to qualify it with the class name.
Note:
import static java.lang.System.*;
class StaticImportExample{
public static void main(String args[]){
out.println("Hello");//Now no need of System.out
out.println("Java");
}
}
Hello
Java
Note: also read about the Packages in Java
If you like my post please follow me to read my latest post on programming and technology.
https://www.instagram.com/coderz.py/
https://www.facebook.com/coderz.py
Staying up to the mark is what defines me. Hi all! I’m Rabecca Fatima a keen learner, great enthusiast, ready to take new challenges as stepping stones towards flying colors.
Problem Statement: Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. Example…
Given an integer A. Compute and return the square root of A. If A is…
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where…
A heap is a specialized tree-based data structure that satisfies the heap property. It is…
What is the Lowest Common Ancestor? In a tree, the lowest common ancestor (LCA) of…