Sei sulla pagina 1di 8

Topic 1: Description of Java

Source code: m is a text file received by the compilator, converting it into an object program or bytecode. Methodology of programming: is the methodology of the need to solve problems through the use of algorithms. Algorithm: is a method that contains an ordered sequence of steps that lead to the resolution of a specific problem. Developing algorithms helps us to structure problems and visualize more clearly the solution. Parts of the algorithm: Entrance, Process, Exit Java: is a programming language of general purpose that was created by Sun Microsystems with the objective of creating a language that could operate in any platform or operational system. To date Java has released different versions of Java Development Kit like JDK 1.1, JDK 1.2. J2SE (Java 2 Standard Edition): Group is made of packaged of Classes of general use. We can include in this classification those applications that run on the web or on a text processor. J2EE (Java 2 Enterprise Edition): Provides packages and technologies necessary for the creation of multiple business applications, especially for those that run in a web environment, such as an e-commerce application installed in a companys webpage. J2ME (Java 2 Micro Edition): This group includes a series of packages that enable the creation of Java applications on electronic devices such as cell phones, electronic agendas and PDAs. It could be the card game installed on your cell phone.

Topic 2: Analysis of a problem; design of a solution


Class model (graphically) Class: animals Attributes color Size weight soft drinks First we define the attributes, properties that distinguish one object from another: Size, Flavor, Content,Brand Methods walking() eating() sleeping()

Next we will define the methods, the actions that you can execute with the object. Opening it, Closing it, Shake it Define objects: e, is a unit code that contains a series of operations that can be used by programs to execute certain tasks. Attributes: characteristics of objects. Methods: The operations that an object can execute Object: in Java language, is a unit code that contains a series of operations that can be used by programs to execute certain tasks. Parameter: The information that requires a method to operate Class: can be defined as a category to group objects that share characteristics and/or similar attributes.

Topic 3: Introduction to Java


Data types Integer

byte -128 to 127 short -32768 to 32767 integer -2147483648 to -2147483647 long 9223372036854775808 to 9223372036854775807 Decimals

float 3.4 x 10-38 to 3.4 x 1038 double 1.7 x 10-308 to 1.7 x 10308 Characters

char Single character Logic

boolean True / False

Logic operators AND: Is represented by the following symbols: &&and returns true only when both conditions are true, else returns false. OR: Is represented by the following symbols: ||and returns false only when both conditions are false, else returns true.

NOT: Is represented by the symbol: ! Affects only one condition and returns true if it has the value of false and vice versa. XOR: Is represented by the symbol: ^ and returns the value true as long as one condition is true and the other is false, else returns false.

Topic 4: Developing and testing a Java Program


Structure of the object: An object is made of methods, which define the behavior of objects (operations), and of attributes and fields, while define the state of the object. Attributes: Define the state of the object Methods: Operations that define the behavior of an object Constructors: Part of the methods that allow an object to be created Destructors: Part of the methods that let you destroy an object Public: Is used so the method can be used anywhere in the program Static: No other object can be used in this method, it is independent from the rest. Void: The method, when ending its use, wont return any result. Statement to show a message on computers screen: (..)

Topic 5: Declaration, initiation and use of variables


Variables attributes: are declared outside of a method and their syntax is the following: Modifier Data_type Name_variable Modifier: Public or private Data_type: Any primitive data type Name_variable: Must follow the mention characteristics Local variables: are declared inside a method and their syntax is the following: Data_type Name_variable Initiate variable. Both variable types can be initialize in the same line

Topic 6: Use of operators and decision constructions


If else (use): The instruction if / else is a complement of the instruction if and allows certain condition to be executed in case the condition is met or if the condition is not met. Example: if( age>=18)

{ System.out.println(He is of age); } else { System.out.println(He is underage); } Switch (use): is a statement of multiple alternatives that allows you to perform certain instructions to the result of the expression. Conditional operators: <: If the left operand is less than the right operand, returns true. >: If the left operand is more than the right operand, returns true. !=: Compares two values, in case they are different returns true == : Compares two values, in case they are equal returns true <=: If the left operand is less than or equal to the right operand, returns true. >=: If the left operand is more than or equal to the right operand, returns true.

Topic 7: Use of loop constructions


Do while (use) While : certain instructions to execute while a determined condition is met, e requires an expression to evaluate that generates a true or false result. The instruction do/while is similar to the instruction while, the difference is that the condition will be evaluated at the end of the executed instructions. Break (use): exit of a cycle, puts the end to a block of instructions when making use of the instruction switch, break ends the cycle inside a loop.

Topic 8: Creation and use of objects


Instantiate of an object: you create it with the new operator, for example: new house() Reference variable: Syntax to define the reference: Example Country house; . With the operator "." (dot) you assign a reference variable to an object.

Topic 9: Implementation of encapsulations and constructors


Encapsulation: refers to the action of hiding data in a class (a security capsule) and makes them available only through certain methods. Public modifier: makes the class, attributes and methods visible to any object. Private modifier: prevents that other objects can access the objects of a certain class, such as attributes and methods. Constructor: is a special method that is executed at the moment you create a class object. They can be reused.

Topic 10: Implementation of inheritance


Inheritance is one of the main concepts in object oriented programming. Inheritance: is the capacity of creating a class that will automatically acquire the attributes (methods), from other classes that already exist Superclass: is the class that contains methods and attributes that will be inherit to the subclass. Subclass: receives the attributes and methods of the superclass. The subclass includes the word extends and the name of the class. Abstraction: creation of abstract classes. Abstract class: is a class in which objects cannot be created, is a class used to be inherited by others and is defined as a superclass since its creation. Java class packages:
Package java.awt java.applet java.net java.io java.util Description of the classes it contains Contains classes that have tools to build and manage the graphic interface that includes the management of windows. Contains classes that provide the management of the applets. Applets are objects that allow programs created in Java to run from a web page. Contains classes that allow you to perform network-related operations. Contains classes that allow you to manipulate files, as well as reading and writing operations from a disk. Contains classes for tasks such as generating random numbers, date operations and calendar functions.

Word import: use it to make use of a package in a Java Program.

Topic 11: Development and use of methods


A method is declared inside a class.

To call a method, you need to write the name of the variable and the name of the method separated by a point. housejavier.show_info();

Worker method: is an execution method and it executes an action. Call method: is a method that calls another method to execute an action. The call method sends the worker to perform certain actions and waits until the worker finishes its action to proceed with the rest of the program. "Static" modifier: can be called without having to initialize a variable that refers to an object and can also be called by more than one class, meaning, they are not specific to a class in particular. Methods that use the "static" modifier can be accessed by any method from any other class in the program. Method overflow: methods in a class that have the same name but have different arguments.

Topic 12: Creation and use of matrixes


Matrix: is an object in which you can store a set of data of the same type. Matrixes: are known as arrays. Matrix or array: is defined based of the number of dimensions. uni-dimensional matrix: one dimension matrix Can be declared using the syntax: Data_type Matrixname[]; You can then add the following instruction: Matrixname = new datatype[length];
Example: int m[]; m=new int[16]; //Matrix with the name of m that stores integer values. // length of the matrix is 16.

bidimensional matrix: two dimensional matrix

Bidimensional matrixes are initialized in the same way as unidimensional matrixes with the difference that we add another pair of brackets. Example: int s[ ][ ]; s=new int[10] [15];

//bidimensional matrix of infinitite size called s. // length of 10 times 15

tridimensional matrix: matrix with three dimensions

Topic 13: Specific algorithms


Recursion: when a method is calling itself. A method calls itself to delimit the end of a call, with the intention of identifying the moment in which a function returns an expected result and to avoid that the program loops indefinitely with the same method. Methods to sort data: - bubble method: 1. Compares the first element with the second one, the second one with the third, and so on. When the result is higher (or lower) than the previous one, they exchange values. This way we can take the highest value (or lowest if we like) to the last position. a. The comparison of each element can be done by a logic operator, for example: to compare two variables we can make use of the instruction:If (a>b). 2. Repeats the point 1 for the n-1 first elements of the list.

3. Repeats the point 1 for the n-2 first elements of the list and so on until you finish with all the elements.
public static void bubble(int [] array){ int aux; int i; int number_of_elements= array.length; boolean s=true; while ((s==true) && (--number_of_elements > 0)){ s=false; for (i=1; i<= number_of_elements; i++){ if (array[i-1]>array[i]){ aux=array[i-1]; array[i-1]=array[i]; array[i]=aux; s=true; } } } }

Insertion method: The first two elements of the array are ordered initially, and then the third element is inserted in the correct position in respect to the previous ones, and so on. This is done until the last element has been inserted.
public static void insertion(int [] matriz){ int array[40]; double x; int i, k; int number_of_elements= array.length; for (i=1; i<number_of_elements; i++){ x=array[i]; k=i-1; while (k>=0 && x< array[k]){ array[k+1]= array[k]; k=k-1; } m[k+1]=x; } }

Potrebbero piacerti anche