Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Java Basics

For Training
by

Gaston D'Apice

on 11 January 2013

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Java Basics

Visit java.sun.com
Find a link to download the Java SE 6 (the JSE, version 6). Downloading and Installing the Java Development Kit (JDK) J2SE - Java Standard Edition J2EE: Java Enterprice Edition J2ME - Java Micro Edition Versions of Java Download the JDK, not the JRE!!!! Double-click the icon of the downloaded file and follow the wizard's instructions for installing the JDK.
Among the features that you select to install, make sure you select Development Tools and Public Java Runtime Environment.
Jot down the name of the directory in which the Java SDK is being installed and then click Next.
Enjoy the splash screens that you see while the software is being installed. Simple
Object-Oriented
Distributed
Multi-Threaded
Secure
Platform-independent The Java programming language is a high-level language that can be characterized by all of the following key words: Is a programming language easy to understand.

The Memory is dynamic

The Garbage Collector, deletes the objects of the memory that are no longer used.

Uses inheritance simple, the inheritance multiple is no longer used. The application can be accessed from internet or intranet due to it can be stored in one or more servers Simple: Object-Oriented Distributed: Multi-Thread: It can execute many tasks at the same time:

Access to a Database

Printing

The server can be managing a web page

Among others... Secure: Java does not allocate direct pointers to memory, like C/C++. This makes it impossible to accidentally reference memory that belongs to other programs or the kernel. If you know more about memory management then you can see how this is really useful.

The Java compiler catches more compile-time errors; other languages will compile programs that produce unpredictable results. Specially with the C/C++, like int value start over once the upper limit is exceeded. Platform-independent It possibly can be the programming language that is more object-oriented than any other; in Java EVERYTHING, except for the fundamental types of variables (int, char, long, etc...) is an Object!

Unlike C language, the OOP is not lineal or structured, the OOP has interaction among their objects, in other words, we can say that the objects can communicate through messages. What is
a Software? Java Java technology is both a programming language and a platform. The Basics Programming When a file *.class is created, the application can be executed on any platform that has installed the JVM:

Linux / Unix

Mac OS

Windows Implementation Design End-of-Life Development Analysis Manteinance Test OK! Now I understand the features of Java but, when
do we start programming? Compilation Process Features of Java What you should know about
a Software Application Is a collection of computer programs and related data that provides the instructions for telling a computer what to do and how to do it. In a few words..... Life Cicle of
an application Analyze the requirement
Get all the information about it to identify the goal of the application
Identify the problem of the current process
Identify the main components of the system Create de documentation of the application using the UML Language. Transform the requirement into code Do different tests of the application to know if it has "bugs" / problems Package the software and put it into ready state Make improvements or changes to the application End of life cycle and version the application to take an order. OK then, Lets get started Basic Components
of a Java Program Process of Compilation Template to create objects.
With a class you can create as many instances as you need. Class: {} public class Shirt [modifier] [class] [identifier] public class Shirt {

} Declaration of a class Declaration of variables Syntax of a method public int shirtID = 0;
public String description = “-description required-”;
public char colorCode = ‘U’;
public double price = 0.0;
public int quantityInStock = 0; public [modifier] [data_type] [identifier] [= value] int shirtID = 0; public void displayShirtInformation() {

} // Your code here public [modifier] [return_type] [identifier] [braces] void displayShirtInformation() {} [Comments] // One line comment /*
* Block Comment
*/ [braces] First, we need to create a Java program in either a plain text editor (Notepad, Notepad++, etc...) or an IDE Integrated Development Environment) and save with a .java extension

The Java compiler (javac.exe) check the file for syntax error.

If the compilation is successful, the resultant is a file with a .class extension; this file is passed to the Java Virtual Machine [JVM] (java.exe) for execution. Follow the next steps: Configure the PATH environment variable Press the 'Window' button plus 'Pause/Break' button.
or
Go to Start, Right click on 'Computer' (or 'My PC')
Select 'Properties' from the menu.
or
Go to 'Control Panel' and Click on 'System' icon.

On the left menu select the 'Advanced System Settings' option.

In the window 'System Properties' click on the Environmental Variables

Then on the 'System Variables' list, search the 'PATH' variable and double click on it.

At the end of the line write a ';' and then write the route of the Java Bin Folder. For example:

';C:\Program Files\Java\jdk1.6.0_31\bin;'

Click Ok, Ok, Apply and Ok.

Now you got the Environmental Variable configured. Now, lets write our first program! Understanding a little bit more about Java Data Types Reserved Words Constants and Operators Operator Precedence Primitive type conversion Handling Objects What is a variable? Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.
Variables have a Data
Type An operator is a symbol that operates on one or more arguments to produce a result. The 'Hello World' program is so simple it doesn't use any operators, but almost all other programs you write will. There are eight primitive data types supported by Java.

Primitive data types are predefined by the language and named by a key word. Primitive Data Types Reference variables are created using defined constructors of the classes. They are used to access objects. These variables are declared to be of a specific type that cannot be changed. For example, Employee, Puppy etc.

Class objects, and various type of array variables come under reference data type.

Default value of any reference variable is null.

A reference variable can be used to refer to any object of the declared type or any compatible type. Reference Data Types Example : Animal animal = new Animal("giraffe"); There are few keywords in Java programming language. Remember, WE CANNOT USE these keywords as identifiers in the program. The keywords 'const' and 'goto' are reserved though, they are not being currently used. To declare a constant variable we use 'final' instead of 'const'

The value of the variable cannot be changed.

The identifier name must be in all upper case letters with the underscore used to separate words. Constants Example : final String TEXTO_PRINCIPAL = "Hello World"; Operators Arithmetic Increment / Decrement This table is going to be applied when we have an expression with more than one operator.

This will help us to know which operator apply first and which later in the expression. Reference Data Types Is the process to convert a variable type into other type. You must have in mind the lost of precision when you do a conversion. Is to create a reference on the Heap Memory to access the methods or to modify the attributes of the objects. For this we need to define the data type (Class Name) and an identifier (Variable Name) Shirt myshirt; [Class Name] [Identifier] Stack Memory Heap Memory Short storage Memory myShirt yourShirt Long storage Memory 0x034009 id = 1;
colorCode = 'G';
price = 10.0;
size = "small" 0x99f311 id = 1;
colorCode = 'G';
price = 10.0;
size = "small" 0x034009 0x99f311 Then the reference of memory is assigned
to the identifiers 'myShirt' and 'yourShirt' myshirt = new Shirt();
yourshirt = new Shirt(); With the operator 'new' we create a new object which is located in the Heap Memory and it identifier is a memory location. You can create as many objects as you wish, and those will be stored in the Heap Memory. To access to the attributes or method of an object we use the operator '.' (dot). myshirt.colorCode = 'R'; An object can be referenced by many variables, but a variable only can reference one object.
Full transcript