Submitted by heartin on Sat, 10/25/2014 - 22:16
The main method is the entry point to a desktop based core Java application.
Previously, we created our first Java program "Hello.java" as:
public class Hello {
public static void main(String[] args)
{
System.out.println("Hello");
}
}
We then compiled it using javac as:
javac Hello.java
We then executed it as:
java Hello
And output should be:
Hello
Submitted by heartin on Fri, 10/24/2014 - 22:42
To access a class or method from another package we need to either use the fully qualified name (e.g. com.javajee.MyClass) or we can use the import statements.
Using import statement
You can use an import statement to import a single class (import java.util.List;) or all classes of a package (import java.util.*;). Remember that you can import only types (classes and interfaces, but not methods) using a regular import.
Consider an example:
Submitted by heartin on Tue, 11/13/2012 - 00:02
Packages are used in Java for organizing your class files. It is similar to folders to organize your files within your file system. You can put related class files together in one package. Java groups predefined classes into different packages like java.lang, java.util, java.io etc.
Submitted by heartin on Fri, 10/19/2012 - 22:33
Wrapper classes
The wrapper classes provide a mechanism to "wrap" primitive values in an object so that the primitives can be included in activities only for objects, like being added to Collections. There is a wrapper class for every primitive in Java. The wrapper class for int is Integer and the class for float is Float and so on. Wrapper classes also provide many utility functions for primitives like Integer.parseInt().