Looking for the best in Help Desk Software, visit Novo Solutions.

Introduction to Java 5

January 13, 2011

The last major version of the Java platform was 1.2. It was so important, indeed, was the language known as Java 2. Java later released several new features and fixes, but nothing too excited. Java 5 (JDK 1.5), is another great piece!

In this article I will show you the most exciting additions to the language. I’ll show you why Java is stronger than ever and in many cases easier to use. Let’s start by looking at called a slick new device autoboxing.

auto auto boxing boxing is a language feature that the programmers life much easier when it comes to working with primitive wrapper types. Consider this excerpt:

int num = 23;
Integer numObject = new Integer(num);

Wrap the primitive objects, like the whole class is loaded, you treat Java primitive types as if they were possible objects.

Accordingly, it is to  package  specifies the primitive type with the corresponding primitive wrapper object, as stated above.

Forget all that! Java 5, you can:

int num = 23;
Integer numObject = num;

it seems a little strange at first: We are an object of type Integer, and have assigned a primitive! How can that be? A primitive is a primitive and an object is an object and never the TWAIN shall enter into force, is not it? In all cases, the additional step of adjusting the original no longer necessary. Was  automatically in the fields  in their name.

Unboxing uses the same process in reverse. Consider the following snippet of a moment:

Boolean canMove = new Boolean(true);

if(canMove){
System.out.println(“This code is legal in Java 5!”);
}

What is the problem? Look closely: the  if  requires a boolean primitive, but gave a Boolean wrapper object. No problem! Java 5 automatically  release  for you.

Note that the compiler generates wrapper missing, so not really something to gain in performance. Please note that this feature does not improve the convenience for programmers, performance.

Personally, I like this new language much function. My only problem with it, that the boundary between object and primitive types tends blur (I have always liked the fact that the distinction between them was very black and white). I can not complain, though. Microsoft C # language is the idea a little further – you can even call methods directly on primitive!

Var argsIn Java specifications methods are more or less real. For example, a method that declares two parameters of a particular type be called with these parameters. If the offer again very little when the settings are correct, you will get a compiler error. Of course, the method overloaded with cases in which we have to treat declare a variable number of parameters or the type.

But sometimes it makes sense or is more convenient for the method of treating any number of arguments that are thrown their way, so how to do it in languages such as JavaScript and ColdFusion. How many developers were before the simulated behavior as in Java to create an array of parameters, then go along the network as an argument for the desired method.

Tags: , , , , , , , , , , , , , , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

UK Webmaster SEO Forum