Java Tutorial
IntroductionEnvironment SetupIDEBuild ManagementLanguage SpecificationBasic ProgramVariablesData TypesPackagesModifiersConditionalsLoopsObject OrientedClassesSuperInterfacesEnumStatic importInheritanceAbstractionEncapsulationPolymorphismBoxing & UnboxingConversion Formatting numbers Arrays Command line arguments in java Variable Number of arguments in Java Exception handling in Java String handling in Java StringBuffer and StringBuilder in Java Mathematical Operations in Java Date and Time in Java Regular expressions in Java Input output programming in Java File Handling Nested Classes Collections Generics Serialization Socket programming Multi-Threading Annotations Lambda Expressions Reflections in Java Singleton class in Java Runtime Class in JavaHow to load resource in JavaHow to load properties file in JavaAdvanced
Log4j – Logging framework in JavaInterview Questions in JavaTo import specific member say class in a package in Java, we use below syntax. import static java.io.File; To import all members in a package in Java, we use below syntax. import static java.io.*; Both the statements above will import the members in a package like classes, interfaces etc. With static import, it is possible to import the static members of the class. For example – to import all static members in Math class, we can use below syntax. import static java.lang.Math.*; Below example explain how to use static import in Java.
package static_import;
import static java.lang.Math.*;
public class StaticImport {
public static void main(String [] args){
//Without static import, you will have to use
//Math.sqrt to invoke method.
System.out.println("Square root of 625 is - > " + sqrt(625));
}
}
Here is the output of above Java code.
Square root of 625 is – > 25.0
Web development and Automation testing
solutions delivered!!