Tiger is the code name of Java 5.0 during its development. Then Sun gave the name J2SE (Java2 Standard Edition) 1.5. But compared with J2SE 1.4, J2SE 1.5 has some very important changes to Java language. So Sun preferred to call it as J2SE 5.0 to signify major changes to language.
The new name gave by Sun is Java SE 5.0 (they are dropping 2 from name as it refers to Java2 and now Java2 is not appopriate any more).
C++ is a powerful and flexible language used mainly in system programming.
Java is a roubust and platform independent language which is used to develop business and internet applications.
A lot of features of C++ are not found in Java and vice-versa.
C++ features not in Java
- Pointers
- Friend functions
- Operator overloading
- Default function arguments
- Function and class Templates. Java has Generics (which are simlar to Templates though not same) in version 5.0
- delete keyword
- Multiple inheritance
- Types of derivation - public, private and protected.
Java features not in C++
- Interfaces
- Packages (Namespace added later to C++)
- Default access method
- Multithreading
- Applets
- Garbage Collection
- Standard classes for Collections, Network programming etc.
JAR (Java Archive) file contains a collection of packages and classes. It is used to distribute packages and classes.
Jar file is created using JAR.EXE, which is found in BIN directory of JDK. For example the following command creates a jar file with the name srikanth.jar and contains all .class files in the current directory.
jar cvf srikanth.jar .To use classes of a jar file one has to keep jar file in CLASSPATH.
Assume we have First.class and Second.class to be placed in a jar file test.jar. We want First.class to start execution when user runs test.jar.
Create a manifest file with the name test.mf as follows:
Main-Class: FirstNote, we should not mention the .class extesion for the file in Manifest file.
Create test.jar file as follows:
jar cfm test.jar test.mf First.class Second.classYou can now either double click .jar file in explorer to start running First.class of test.jar or you can run it with java as follows:
java -jar test.jar
An object must be serializable if it is to be written to disk or transfered in distributed applications.
The following example shows class Student implementing this interface to indicate to Java that its object can be serialized by Java.
public class Student implements java.io.Serializable { // body of class } Whereas an abstract class can contains abstract methods without any body but it can also have non-abstract methods with body (which is not possible with interfaces).
Interfaces cannot contain instance variables
Abstract class can contains instance variables.
However, interface and abstract classes can not have objects. They can only have object references which point to object of implementing class or sub class.
The following are important null interfaces in Java.
- java.lang.Cloneable
- java.io.Serializable
- java.rmi.Remote
public enum Suit { CLUBS, DIAMONDS, HEARTS, SPADES } for (Suit suit : Suit.values()) { System.out.println(suit); } Calendar cal = Calendar.getInstance(); cal.add(Calendar.DAY_OF_YEAR, 1); Date d = cal.getTime();
ProcessBuilder processBuilder = new ProcessBuilder( command, arg1, arg2); processBuilder.directory("DirectoryLocation"); Process p = processBuilder.start(); This major release included over a dozen JSRs and nearly 100 other significant updates from the JCP. You should note that this can also be considered developer release 1.5.0.
This release included features such as the addition of generics, an enhanced for loop, enumerated types, static imports, automatic boxing of primitive types and much more.
Tiger is followed by the "Mustang", which will be J2SE 6.0 (1.6.0), which in turn will be followed by "Dolphin", which will be J2SE 7.0 (1.7.0).
The Mustang release of J2SE is expected to include a number of key changes to J2SE including changes to the release model of the JDK, XML and Web Services, Transparency, Ease-of-Development improvements, better compatibility, an updated to the API for accessing JDBC, and the addition of a scripting engine. There will a refined GUI as well as graphics performance improvements.
class Test { public static void main (String args[]) { System.out.println("Loaded Test from:" + Test.class.getProtectionDomain().getCodeSource().getLocation()); } } float f; f = 10.50;
Vector v = new Vector(); // v.add(10); -- cannot be done v.add ( new Integer(10)); // int 10 is converted to object of type Integer class.
No comments:
Post a Comment