Posted at 10.15.2018
Java can be an object-oriented programming language developed by Sunshine Microsystems in 1991 and first released in 1995. Its development was led by the "Green Team", managed by the flagship programmer James Gosling. Initially was to be called "Oak", and there are many ideas of why this name, being the most accepted the actual fact that there is an oak tree (Oak in English) contrary to the Green Team office. That name turned out to be little commercial locations, aside from already having been documented. Finally, at the offices of Sun, it was made a decision to call it Java.
Java will not take long to attain the hearts of desktop developers, providing a system multiplatform and strong for designers. In its beginnings still left much to be desired in the graphical interface, because the original graphics library, AWT (Abstract Screen Toolkit), was much attached to the operating system and employed in targeted insects, in other words, bugs specific to each operating system.
This is a problem for any creator, since it is obligated to test their program on each operating system. But with the looks of Swing, the existing library of graphical user interface, each one of these problems were solved.
However, the biggest market of Java now could be targeted at server applications, offering in the platform J2EE a variety of tools to develop secure systems, scalable and powerful.
Java, rather than programming language, was developed considering a technology or platform. Three different tastes are recognized, each centered on a particular need:
J2Me personally: Java Micro Model, destined for develop mobile applications. It is developed taking into consideration the limited resources that contain a mobile device.
J2SE: Java Standard Model, for the world of desktop applications. It's the core of the vocabulary; containing the bottom of the API (Software Programming User interface) this offers us.
J2EE: Java Organization Edition, for the systems business. It is built on J2SE, but by adding a big security API, giving the designer all the tools necessary.
Today Java is present in every field of modern programming, from telephones to biggest machines, but the key of its success, beyond the fantastic API that offers and its own syntax, has been the JVM (Java Virtual Machine), the main element piece in this masterpiece.
It is in charge of interpreting the bytecode and executes the claims. It also provides the Garbage Collector, a collection of resources "unattainable" in the application, which allows the designer to concentrate on the logic, and get worried less about the memory space leaks.
Ok, we noticed the history of Java, but what is Java?
In theory is defined as a multiplatform terms and object-oriented, but these are terms that only a specialized person can understand. In basically conditions, Java is a program writing language able to operate on any operative system and implements a paradigm that facilitates the maintenance of the application.
Java, like any programming language object-oriented, is determined by Classes and Items. A class is only a template from which an object is created. But once again, this can only be realized by a specialized user. In basic words, a class is a blueprint that it is possible to create a building.
We know that from a class we can develop an thing, but what is an thing? Simple, an thing is an occasion of a course. Following our past example, a building would be an object (since it was built from a airplane).
The objects in real life have features and functions. For instance a individual is an subject with several traits: color, weight, height, attitude, and also offers several functions: eating, walking, conversing, etc.
The same concept applies to items in Java; an thing has qualities and functions. Characteristics describe the object and functions will be the actions that objects can execute. For example, the object calculator may contain the attribute "buttons" and the function "add".
We have previously seen part of "object-orientation, " but what can be a multiplatform? To explain this concept we have to bring in another: machine code. For machine code we refer to instructions some type of computer can understand. The disadvantage is that code should be written separately for each operative system; so for example if we develop a credit card applicatoin in machine code, we have to write that code various ways according to the operative system. Here comes into play our good friend "multiplatform". Whenever we say a words is multiplatform, refers to the actual fact that the same code works on any operative system. Yes, only be developed once and our program can run on any system.
We already know the storyline and what is Java, but how to use Java? Before this, we have to know "talk" java; we must know its syntax.
Syntax is the set of laws and regulations must be implemented when we are developing in Java. It is a lot like the spelling rules which exist in all human terminology.
In all syntax of any program writing language there are keywords or reserved words. What is this? Nothing more than words reserved by Java for personal use and then the programmer cannot utilize it in his code.
These keywords are:
abstract continue for new switch
assert default goto bundle synchronized
boolean do two times private this
break double implements protected throw
byte else import public throws
case enum case of go back transient
catch expands int brief try
char final interface static void
class finally long strictfp volatile
const float native super while
Each of these keywords provide a function in Java, but we will them see later.
As we observed recently, Java is object focused, so has features and functions. In the world of Java these are called parameters and methods. A variable is a reserved space of ram, that means a data box. Each variable must have a data type. A what? A data type is the type of principles this variable can take: numbers, heroes, Boolean, dogs, felines, etc. The syntax for declaring a changing in Java is:
Later we will have what every one of them is about.
We found the variables or capabilities, but what about functions? From now on we will call them "methods". One method is a stop of code to be carried out in an orderly and sequential way. The syntax for declaring a way in Java is:
Again, do not be anxious about knowing what which means for the present time.
We have observed the objects, but it's time to start to see the classes. As mentioned above, a course is a template from which an object is created, therefore, the class must contain all the information that describes the object. The syntax for declaring a course in Java is:
Previously we saw these words repeated several times, "access modifier", but what's this? From a technical point of view, these are constraints that put on members of an class, access limitations, meaning, who are able to and who cannot gain access to them.
In Java there are four access modifiers, and three of them are keywords of the vocabulary:
public, covered, private and default.
default modifier: This is the modifier that assigns the online machine to any member if no one has been informed directly. This modifier restricts use of the member only classes that are declared inside the same package as this one.
public: Is the modifier most permissive of all, because offers to the member usage of any class declared with this swap.
protected: Is the second most permissive. It is equivalent to the modifier by default, only stretching access to any course that inherits from the course comprising the member. Inherit? Yes, classes can be inherited, but we will see later.
private: May be the modifier most restrictive of most. A member declared with this modifier can only just be accessed from within the course.
As mentioned above, public, secured and private are keywords in Java and can't be used as identifiers, that is, as category names, parameters or methods.
I believe the name is very intuitive, these modifiers work on how when a member behaves. Altogether, they are simply seven and are also keywords of Java. They are:
static: Whenever a member is declared as static, ceases to belong to an instance associated with an thing and becomes part of an class.
abstract: Whenever a member is declared as abstract, this member will lack of implementation and can take only a signature.
synchronized: Whenever a member is declared synchronized, this member will limit his usage of only one thread at a time.
strictfp: When a member is declared with this modifier, floating point beliefs shall be governed by a couple of special rules and can depend on the implementation of each Digital Machine.
volatile: Changes made to a volatile member is effective only if each of them go into impact, which means, if the worthiness is changed three times, these three changes enter into effect only when the three changes go into effect.
native: An associate declared as indigenous will possess your body of its explanation in machine code.
final: This indicates what value of an associate can't be changed.
We mentioned previously a data type identifies what forms of values may include a variable. In Java there are primitive data and guide data. Primitives are those that are not defined in a school; and research is the in contrast, are the ones that are defined by a class.
All primitives are keywords in the language and are the following:
byte: Refers to a complete numeric value with a limit of 8 a
short: refers to a whole numeric value with a limit of 16 bits
int: identifies a whole numeric value with a limit of 32 bits
long: identifies a whole numeric value with a limit of 64 bits
float: identifies a decimal value with a limit of 32 bits
double: refers to a decimal value of 64 bits
char: identifies a identity and has a limit of 32 bits
boolean: refers to a Boolean value, that is two expresses.
Reference types can be any existing course in the Java API or identified by an individual.
We have perfected the theory, but go to apply. We realize the syntax to declare a class and its people so here we go:
All this will go ahead a report with the same name of the course and result in (. java), in our case would be a file HelloWorld. java
We have just seen the standard example, a class declared general public with the name HelloWorld. It contains a private changing and constant, a open public and static method, which directs to printing on console the worthiness of the adjustable number.
But writing this code is insufficient, we should now put together. Java offers a couple of tools for coders called JDK (Java Development Kit) and included in these are a compiler.
To compile this code we visit a console and type:
To run our code we should use another tool found in the JDK: