1 - Introduction To Java (Only When Required)
1 - Introduction To Java (Only When Required)
JAVA INTRODUCTION
JAVA BASICS
● int - stores integers (whole numbers), without decimals, such as 123 or -123
● float - stores floating point numbers, with decimals, such as 19.99 or -19.99
● char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
● boolean - stores values with two states: true or false
● String - stores text, such as "Hello". String values are surrounded by double quotes
JAVA OPERATORS
Java divides the operators into the following groups:
● Arithmetic operators
● Assignment operators
● Comparison operators
● Logical operators
JAVA OPERATORS
Java divides the operators into the following groups:
● Arithmetic operators
● Assignment operators
● Comparison operators
● Logical operators
JAVA OPERATORS
Java divides the operators into the following groups:
● Arithmetic operators
● Assignment operators
● Comparison operators
● Logical operators
JAVA OPERATORS
Java divides the operators into the following groups:
● Arithmetic operators
● Assignment operators
● Comparison operators
● Logical operators
You can use these conditions to perform different actions for different decisions.
● Statement 1 is executed (one time) before the execution of the code block.
● Statement 3 is executed (every time) after the code block has been executed.
It is a programming paradigm, that is, a style of program development or a model for solving
computational problems.
It is a highly recommended paradigm, with which you can write ordered code and applications that are
easier to maintain.
Defines the
structure of
Attributes Methods
Store their features and
Objects Communicate between
state on them with
WHAT IS A CLASS?
WHAT IS A METHOD?
A method is a block of code which only runs when it is called.
WHAT IS AN OBJECT?
telefono.llamar("Pablo");
telefono.cortarLlamada();
telefono.informarCaracteristicas();
ACCESS MODIFIERS
• Attributes are generally accessed through the get and set methods, since it is
strictly necessary that the attributes of a class be private.
WHAT IS ENCAPSULATION?
It makes sure that "sensitive" data is hidden from users. To achieve this, you must:
WHAT IS INHERITANCE?
In Java, it is possible to inherit attributes and methods from one class to another. Inheritance concept
could be grouped into two categories:
WHAT IS INHERITANCE?
In Java, it is possible to inherit attributes and methods from one class to another. Inheritance concept
could be grouped into two categories:
To inherit from a class, use the extends keyword. It allows code reutilization rather than rewriting
WHAT IS INHERITANCE?
Superclass
Subclasses
public class Professional{ public class Engineer extends Professional{
WHAT IS POLYMORPHISM?
WHAT IS ABSTRACTION?
It is the process of hiding the implementation details from the
user, providing only the functionality to the user. In other words, the
user accesses the information of what the object does, rather
than how it does it.
WHAT IS INTERFACE?
Another way to achieve abstraction, is with interfaces.
JAVA ENUMS
An enum is a special "class" that represents a group of constants (unchangeable variables, like final
variables).
To create an enum, use the enum keyword (instead of class or interface), and separate the constants with a
comma. Note that they should be in uppercase letters:
public BebidaCerveza(MarcaCerveza marca, Vaso vaso){ private Vaso(String tipo, int cc){
this.marca = marca; this.tipo = tipo;
this.vaso = vaso; this.cc = cc;
} }
//Probando enumerados
public class TestEnum{