Curso Java. Estructuras principales III. Declaración variables Eclipse Vídeo 6

pildorasinformaticas
13 May 201421:16

Summary

TLDREste vídeo tutorial de programación en Java desde cero guía a los estudiantes a través de la creación de una nueva clase en Eclipse. Se repasan conceptos básicos como tipos de datos primitivos, variables y la importancia de la declaración de variables. Se muestra cómo escribir comentarios en el código, declarar variables en una sola línea y cómo cambiar sus valores durante la ejecución del programa. Además, se destaca la utilidad de los comentarios para comprender mejor el código y se enfatiza la orientación a objetos en Java, donde todo es considerado un objeto con propiedades y métodos.

Takeaways

  • 😀 Se da la bienvenida a un nuevo video de curso de programación en Java desde cero.
  • 🔍 Se repasan conceptos vistos en videos anteriores, como tipos de datos primitivos y la declaración de variables.
  • 💻 Se instruye sobre cómo abrir y utilizar Eclipse para crear una nueva clase y repasar conceptos.
  • 📂 Se explica la estructura de carpetas en un proyecto de Eclipse, incluyendo 'src' y 'bin'.
  • 🛠️ Se detallan los pasos para crear una nueva clase en Eclipse y la importancia de la opción 'main method'.
  • 📝 Se discute la inclusión de comentarios en el código para facilitar la comprensión y colaboración en proyectos.
  • 🔢 Se ejemplifica la declaración y asignación de variables, y se explora la diferencia entre tipos de datos como 'byte', 'short' e 'int'.
  • 📡 Se ilustra cómo se utiliza la variable 'age' para almacenar y mostrar valores en la consola.
  • 🔁 Se menciona la capacidad de modificar el valor de una variable durante la ejecución de un programa.
  • 💬 Se enfatiza la importancia de los comentarios en el código y cómo se escriben en Java.

Q & A

  • ¿Qué tipo de datos primitivos se mencionan en el video?

    -En el video se mencionan los tipos de datos primitivos como enteros y decimales.

  • ¿Qué concepto se explicó en relación a las variables en el video?

    -Se explicó cómo se declaran las variables y los tipos de datos que pueden manejar, como los enteros y los decimales.

  • ¿Qué herramienta se utiliza para crear y gestionar los proyectos de código en el video?

    -Se utiliza Eclipse como herramienta de desarrollo para crear y gestionar proyectos de código en Java.

  • ¿Cómo se crea una nueva clase en Eclipse según el video?

    -Se puede crear una nueva clase en Eclipse a través del menú 'File' y seleccionando la opción 'New' o utilizando el atajo de teclado correspondiente.

  • ¿Qué es un 'package' en el contexto de Java y cómo se menciona en el video?

    -Un 'package' en Java es una división en la estructura de directorios que se utiliza para organizar el código fuente. En el video, se menciona que el 'package' debería estar en blanco cuando se crea una nueva clase.

  • ¿Qué método es esencial en todos los programas de Java según el video?

    -El método 'main' es esencial en todos los programas de Java, ya que es el punto de entrada del programa.

  • ¿Qué se hace al seleccionar la opción de crear el método 'main' en Eclipse?

    -Al seleccionar la opción de crear el método 'main', Eclipse genera un marco básico del método main, que es necesario para ejecutar el programa.

  • ¿Qué son los comentarios en Java y cómo se mencionan en el video?

    -Los comentarios en Java son anotaciones que no afectan la ejecución del código y se utilizan para proporcionar información adicional al código. Se mencionan en el video como una práctica útil para ayudar a otros programadores a entender el código.

  • ¿Cómo se declara y se inicia una variable en una sola línea en Java según el video?

    -Se puede declarar e iniciar una variable en una sola línea en Java utilizando la siguiente sintaxis: 'tipoDeDatos nombreVariable = valor;'.

  • ¿Qué tipo de datos se recomienda para almacenar la edad de una persona según lo discutido en el video?

    -El video sugiere que se puede utilizar el tipo de datos 'byte' para almacenar la edad de una persona, ya que el rango de un byte (-128 a 127) es adecuado para representar la edad.

  • ¿Qué significa la advertencia amarilla en Eclipse y cómo se menciona en el video?

    -La advertencia amarilla en Eclipse indica una nota o advertencia, pero no un error. En el video, se menciona que una advertencia amarilla puede aparecer si se declara una variable pero no se utiliza en el código.

Outlines

00:00

💻 Introducción al Curso de Programación en Java

Este primer párrafo introduce un nuevo video del curso de programación en Java desde cero. Se menciona que en el video anterior se discutieron las estructuras de control y los tipos de datos primitivos en Java, como los enteros y decimales. El objetivo de este video es aplicar el conocimiento adquirido en Eclipse, un entorno de desarrollo integrado (IDE), creando una nueva clase para repasar los conceptos vistos. Se describe el proceso de abrir Eclipse, recordar la estructura de carpetas y cómo se guardan los archivos de código, y se explica cómo abrir el proyecto y crear una nueva clase llamada 'variables'. También se detalla cómo se configura la clase con un método principal (main), que es esencial en todos los programas de Java, y se menciona la utilidad de los comentarios en el código para ayudar a otros programadores a comprender mejor el programa.

05:01

📝 Creando y Utilizando Variables en Java

En este segundo párrafo, se profundiza en la creación y uso de variables en Java. Se explica cómo declarar una variable para almacenar un valor, como la edad de una persona, y se discute el rango adecuado para el tipo de dato 'byte'. Se muestra cómo se escribe la declaración de la variable, cómo se le asigna un valor y cómo se utiliza en una impresión en la consola. Además, se aborda la importancia de utilizar variables que ya han sido inicializadas y cómo Eclipse ayuda al programador mediante avisos y sugerencias visuales. Se menciona la corrección de errores y la ejecución del programa, destacando la diferencia entre los avisos amarillos y rojos en Eclipse, y se enfatiza la práctica de utilizar comentarios para mejorar la comprensión del código.

10:03

🔢 Declaración y Asignación de Variables en Java

El tercer párrafo se centra en la declaración y asignación de variables en una sola línea de código en Java. Se ilustra cómo se puede declarar y asignar un valor a una variable en el mismo momento, y se compara con la declaración y asignación en líneas separadas. Se discute la flexibilidad de Java para manejar diferentes tipos de datos, como 'byte', 'short' e 'int', y cómo estos afectan la optimización de recursos. Se muestra cómo cambiar el valor de una variable después de su declaración y cómo estos cambios se reflejan en la salida del programa. Se subraya la secuencia de ejecución del código en el método main y cómo los cambios en los valores de las variables se procesan y se muestran en la consola.

15:07

📝 Comentarios y Espacios en la Programación Java

Este cuarto párrafo aborda el uso de comentarios en el código fuente de Java, explicando cómo se insertan y su función en la programación. Se describen los comentarios de una sola línea, marcados con '//', y los comentarios multilínea, marcados con '/*' y '*/'. Se enfatiza la utilidad de los comentarios para aclarar el código y facilitar la comprensión, especialmente en proyectos grandes con múltiples programadores. Se discute cómo los espacios verticales en el código no afectan la ejecución del programa, pero son útiles para organizar y mejorar la legibilidad del código. Se sugiere la práctica de incluir comentarios en el código para mejorar la comprensión y se muestra cómo se pueden escribir comentarios en varias líneas en Eclipse.

20:10

🔚 Conclusión del Vídeo y Perspectivas Futuras

El último párrafo del guion del video cierra el tema actual y establece expectativas para futuras lecciones. Se menciona que Java es un lenguaje de programación orientado a objetos, donde todo se considera un objeto, incluyendo la consola. Se explica brevemente la noción de que los objetos tienen propiedades y métodos, y se da un ejemplo de cómo la consola, considerada un objeto, tiene un método 'print'. Se anima a los espectadores a seguir el curso para aprender más sobre estos conceptos. Se sugiere que los programadores principiantes acostumbren a incluir comentarios en su código y se cierra el video con la promesa de más contenido en futuras entregas.

Mindmap

Keywords

💡Eclipse

Eclipse es un entorno de desarrollo integrado (IDE) ampliamente utilizado para el desarrollo de software, especialmente en el lenguaje de programación Java. En el guion, Eclipse se utiliza para crear y ejecutar programas Java, mostrando cómo se pueden abrir proyectos, crear nuevas clases y ejecutar códigos. Se menciona que se abre Eclipse, se carga un proyecto previamente creado y se crea una nueva clase llamada 'variables'.

💡Clase

En el contexto de la programación orientada a objetos, una 'clase' es una plantilla que define los atributos (propiedades) y los métodos (funciones) que tendrán los objetos de ese tipo. En el guion, se habla de crear una nueva clase en Eclipse, lo que implica definir un nuevo conjunto de propiedades y comportamientos que luego se pueden instanciar en objetos.

💡Variable

Una 'variable' es un espacio de almacenamiento en la memoria asignado a保存 un valor que puede cambiar durante la ejecución de un programa. En el guion, se discute cómo declarar variables en Java, seleccionar sus tipos de datos y asignarles valores, como en el ejemplo de la variable 'edad' que se declara y se le asigna el valor 35.

💡Tipos de datos

Los 'tipos de datos' son categorías predefinidas de valores que determinan cómo se interpretan los datos en un programa. En el guion, se mencionan tipos primitivos como 'byte', 'short', 'int', que definen el rango de valores que la variable puede almacenar, y se ejemplifica con la declaración de una variable 'edad' como 'byte'.

💡Método main

El 'método main' es el punto de entrada de cualquier aplicación Java y es donde comienza la ejecución del programa. En el guion, se explica que cada programa Java debe tener al menos un método main y se muestra cómo Eclipse ofrece la opción de crearlo al generar una nueva clase.

💡Comentarios

Los 'comentarios' son líneas de texto en el código fuente que no se ejecutan como instrucciones del programa, sino que sirven para proporcionar explicaciones o anotaciones. En el guion, se muestra cómo incluir comentarios en el código Java, ya sea para describir una línea de código o para dejar notas que ayuden a otros programadores a entender el código.

💡Consola

La 'consola' es una ventana de salida estándar donde los programas pueden mostrar información o resultados. En el guion, se utiliza el método 'System.out.println' para imprimir valores en la consola, lo que permite al programador ver los resultados de las variables y otros datos durante la ejecución del programa.

💡Sintaxis

La 'sintaxis' se refiere a las reglas que rigen la estructura y la forma de los programas en un lenguaje de programación. En el guion, se menciona la importancia de la sintaxis correcta, como en la declaración y asignación de variables, y se da ejemplo de cómo Eclipse ayuda a identificar errores de sintaxis con advertencias y bulbos amarillos.

💡Objeto

Un 'objeto' es una instancia de una clase que encapsula datos y comportamientos. En el guion, se menciona que en Java todo es un objeto, incluyendo la consola, lo que implica que tiene propiedades y métodos asociados. Se ejemplifica cómo la consola, considerada un objeto, tiene el método 'println' para imprimir información.

💡Programación orientada a objetos

La 'programación orientada a objetos' (POO) es un paradigma de programación en el que los programas se construyen utilizando 'objetos', que son instancias de 'clases'. En el guion, se menciona que Java es un lenguaje de programación orientado a objetos, lo que significa que todo en Java, incluidos los métodos y las variables, se manejan como objetos.

Highlights

Bienvenida al curso de programación en Java desde cero.

Revisión de conceptos vistos en videos anteriores, como estructuras de datos y tipos primitivos en Java.

Introducción al concepto de variables en Java.

Demostración de cómo abrir y usar Eclipse para la programación en Java.

Creación de una nueva clase en Eclipse para repasar conceptos.

Explicación de la estructura de carpetas en un proyecto de Eclipse.

Cómo crear una clase con un método main en Eclipse.

Importancia del método main en la ejecución de un programa Java.

Uso de comentarios en el código Java para ayudar a otros programadores a entender el código.

Declaración y uso de variables de tipo byte para almacenar valores enteros.

Ejemplo práctico de cómo declarar y asignar valores a variables en Java.

Cómo utilizar el sistema de ayuda de Eclipse para aprender sobre errores y advertencias.

Diferencia entre declarar una variable y asignarle un valor en Java.

Ejemplo de cómo cambiar el valor de una variable durante la ejecución de un programa.

Importancia de la ejecución secuencial de código en Java y cómo afecta a las variables.

Cómo incluir comentarios de varias líneas en el código Java.

Conclusión del video y invitación a seguir el curso para aprender más sobre Java.

Transcripts

play00:01

hello that such welcome everyone to another

play00:03

delivery of this programming course in

play00:05

java from scratch we were seeing

play00:08

in the previous video the structures

play00:09

main language we saw the types

play00:12

of primitive data that are handled in

play00:14

java the data of integer type decimals

play00:16

etcetera we also saw the concept of

play00:18

variable we saw how the

play00:20

variables what we are going to do in this

play00:22

video is to transfer all these

play00:24

knowledge acquired at eclipse

play00:26

let's open eclipse let's create another

play00:29

class to review concepts seen in

play00:31

previous videos and declare we have

play00:32

variables we will handle data types like this

play00:34

that we are going to close the presentation and

play00:37

we open eclipse

play00:39

we remember that we had two folders and

play00:42

specifically on the desk you

play00:43

then you will probably have them in another

play00:45

site one that was called eclipse with the

play00:47

program and another one that we had created

play00:50

to save these codes

play00:52

initials of this course

play00:54

we call that java course folder if

play00:56

we open the java course folder

play00:58

we found the first folder

play01:00

steps that corresponds to the project that

play01:02

we created the first time we opened

play01:04

eclipse and within this folder

play01:06

project because there were two folders

play01:08

main src which is where it is stored

play01:10

the java file and the bean folder that is

play01:13

where they are assembled where the

play01:15

witte code file is the file

play01:17

compiled with java extension if we open

play01:19

src here we have the java if we open it well

play01:22

here we have in class said this we are going to

play01:25

open the program again then

play01:26

we open the eclipse folder double click on

play01:28

the executable

play01:30

and we wait for the program to load

play01:34

once the program finished

play01:36

load then opens the project that

play01:39

we had built the previous video

play01:41

Well, let's create a new class

play01:44

within this project if you have opened

play01:46

the class that we create in videos

play01:49

previous in the in the work area

play01:50

We can close it from your

play01:52

corresponding x without any problem

play01:54

then we close it and what we are going to

play01:57

do as I say is to create another class

play02:00

more then then several options in

play02:02

eclipse if we remember good so let's

play02:05

use another option more

play02:07

to get to know the little program to

play02:09

little if you look at the bar

play02:11

tools then we should have a

play02:13

button that I'm going to point out right now in

play02:14

screen this has as well as a

play02:16

small c whose goal is to build

play02:18

good classes because this is another way

play02:20

of building classes then we click on

play02:23

that button and the window of

play02:25

creation of classes on the one hand has us

play02:27

that indicate the project folder is

play02:30

right on the other hand the package that

play02:32

we still do not know what it is should

play02:34

be blank and then we have the

play02:35

cursor blinking in the name box

play02:38

which corresponds to the name of the class

play02:39

let's call this class

play02:42

for example variables what then you

play02:45

we call variables and we're going to use

play02:48

an option that we did not see in videos

play02:50

earlier we go little by little that is in

play02:52

this window tell you a little bit more

play02:55

downwards so that we build the

play02:57

make method we already mentioned in videos

play03:00

previous that every java program should

play03:02

have at least one main method that is the

play03:05

method from which everything is executed

play03:07

the code is for this poor reason that

play03:09

eclipse in this window offers us the

play03:11

creation of the main method then then

play03:13

we select this check to tell you

play03:16

that we are going to create a main method and

play03:18

click on the finish button

play03:21

I've done these and everything went well

play03:23

you have to create then within what is

play03:25

our project within what is the

play03:27

src folder and within what is the

play03:30

default package that we do not have yet

play03:32

very clear then what does this mean?

play03:34

do you worry two classes the video

play03:36

previous and the class that we just

play03:38

create now that is called variables

play03:39

notice that it already gives you the java extension and

play03:42

if you look at the work area

play03:44

because he has created the class with us

play03:45

name that we have

play03:47

specified access modifier

play03:49

public word reserved class for

play03:51

specify that you are inside a class

play03:52

opening key closing key and

play03:55

it has also built us is already a

play03:56

comfort then what is the main method

play03:59

no and from here we will have to

play04:02

start programming all java application

play04:04

begins to run always from a

play04:07

main method

play04:09

what you see inside the main method and

play04:12

that created us eclipse is what it

play04:13

called in java comments and the only thing

play04:16

what does he do then is tell us this

play04:18

comment that all the code then has

play04:21

to start from here not the

play04:23

comments the program does not have them in

play04:26

account at all is to say at the time of

play04:27

run a program or is the comment

play04:29

as if the comments were not

play04:31

they are small annotations that serve

play04:33

of help or warning code

play04:36

to the programmer to whom you are applying

play04:38

not code and above all they are very useful

play04:41

when in the same project they participate

play04:43

several programmers when in a

play04:45

project involved several programmers

play04:47

it is more than advisable to go including

play04:49

comments that help then those

play04:52

programmers that go behind you to

play04:53

examine the same good code well that

play04:55

help them to understand a little better the

play04:57

code because this instruction exists

play04:59

here because you put this instruction

play05:01

there's etcetera so they do not bother and not

play05:03

I'm going to confuse them

play05:05

comments we can delete them

play05:06

quietly and so I will explain

play05:08

now after how to include comments

play05:10

us manually

play05:13

Well, what we have to do is

play05:14

get inside the main method and go

play05:17

to start declaring variables in a

play05:20

line in two lines let's start

play05:23

variables and we're going to use variables

play05:26

For example, let's imagine that we are going to

play05:28

declare a variable to store

play05:30

because the age of a person because in a

play05:33

future we will need to have it in

play05:35

the program

play05:35

Well, we have several options if

play05:37

remember then the age of a person

play05:40

it has to be more or less between 0

play05:42

and 100 percent and little if not more than

play05:44

a hundred and a little and to be lucky then

play05:46

then we can put that age

play05:50

within a variable of type byte if

play05:52

you remember in the previous video the byd

play05:53

went from the minus 128 negative to 127

play05:57

positive declaration of variables good

play06:00

then bites that is to say data type name

play06:02

of the variable for example age

play06:05

and here, well, we can choose

play06:07

close the sentence with a semicolon

play06:09

with which we have already declared the

play06:11

variable and then later in the

play06:13

code so we can start the is to say

play06:14

name of the variable age equal and the

play06:18

corresponding value semicolon no

play06:21

eclipse as one goes programming

play06:23

Well, it includes a lot of help with

play06:26

which we have to go

play06:27

familiarizing for example if you look

play06:29

to the left of what is the

play06:31

statement of the variable they offer us

play06:33

a kind of balloon or bulb well

play06:35

these are these bulbs that appear here

play06:37

yellow are notices

play06:40

warnings but in no case these

play06:43

yellow warnings means that

play06:45

there is an error if it is the mouse

play06:47

over this warning you will see that

play06:48

eclipse tells you that the value of the

play06:51

local variable age has not been used

play06:55

it means that we have declared the

play06:57

variable we have also started it but

play06:59

at no time of this variable has

play07:00

used that means it's used

play07:03

well then if we now

play07:05

we say that we print the value that there is

play07:07

stored in the age variable in the

play07:09

console should remove this

play07:11

yellow warning that we have both

play07:14

the left as underlining the name

play07:17

of the variable age because already the

play07:18

we will be using something for

play07:20

example system point out point print ln

play07:24

we open parentheses and within the

play07:27

parentheses we put the name of the

play07:29

variable and do not forget to finish the

play07:31

sentence with a semicolon

play07:34

with this instruction we are already

play07:35

using the variable and for that reason

play07:37

x we are already removed the warning

play07:38

yellow because effectively

play07:41

we are using the variable

play07:43

if you remember the previous video os

play07:45

I commented that it can not be used in java

play07:48

a variable that has not been started in

play07:51

our case we have started the

play07:53

variable was equal to 35 but if by

play07:56

any reason this instruction

play07:58

this sentence was not I'm going to

play07:59

eliminate good then in that case fixos

play08:02

as soon as the eclipse is not

play08:04

warns with a red balloon or with a

play08:07

bulb in red and that is to these icons

play08:09

He usually calls them balloons, well

play08:12

warns us that there is an error and

play08:14

when the warnings are red

play08:15

then yes that implies an error of

play08:18

syntax not if we place the mouse over

play08:21

of that warning, yes, it is going to

play08:23

launch a description like that I get it

play08:25

stop a description that to us that

play08:27

We are starting to program, as

play08:29

better we find it difficult to

play08:31

interpret but when we have a

play08:33

little bit of practice and we know a little

play08:34

more the language these warnings yes

play08:37

that are going to be very clarifying here

play08:39

Well, you are telling me more or less

play08:41

that especially this last line is the

play08:43

that gives us the clue that the variable

play08:45

locality then

play08:47

has been started for that good reason

play08:50

It is also underlining us the

play08:52

variable age telling me good then that

play08:54

there is a problem to solve it and it is

play08:57

that this variable is not started if

play08:59

pulse control z to undo the last

play09:02

which says good as you can see

play09:03

and so it takes away the warning and the

play09:07

program works perfectly

play09:10

remembering concepts that we saw in the

play09:12

video past us in this line what

play09:16

what we have done has been to book a

play09:18

space in memory to store the

play09:20

number 35 this what we have done that

play09:22

we do not see it we are consuming

play09:24

x resources to store that value and

play09:27

Later we are telling you that

play09:29

we reflect on the console system point to

play09:31

point print l n the value of the variable

play09:34

age if we press the play to execute

play09:38

this program I remember that in the bar

play09:40

of tools you have a good play

play09:42

well, here eclipse can make two

play09:43

things if you have not saved the button

play09:46

save this code when you click on the

play09:49

play you will get a window

play09:51

intermediate to save the changes

play09:54

if you save the changes and then press

play09:56

the play that intermediate window is omitted

play09:58

notice that I have not saved changes yet

play10:00

because in the name of the file that I

play10:03

da eclipse appears an asterisk is this

play10:05

disk as we saw in videos

play10:06

previous indicates that you have not saved

play10:08

the latest changes made with what

play10:10

which will take pulse in this play

play10:13

Well, as you can see, this is the

play10:14

intermediate window that comes out and this comes out

play10:18

Well, because we have not saved

play10:19

fixed changes that tells me that

play10:22

select resources to save or more or

play10:24

unless you select the program where

play10:26

you want to save the changes of the

play10:29

check activities click on ok

play10:31

automatically saves the changes and in

play10:33

the console so look how

play10:35

effectively we already get the value that

play10:37

there is stored in the age variable

play10:41

this variable that we have declared as

play10:43

byte then we could have declared it

play10:45

how short is perfectly saying

play10:47

as the value that we are going to store in

play10:49

its interior is a good 35 because

play10:51

we tell you how old you are and then

play10:53

age equal to 35 as this works

play10:55

Exactly the same thing that happens is

play10:57

that while declaring it as byte

play10:59

We are reserving a space in the

play11:00

memory to store the 35 when the

play11:03

We declare what we are

play11:05

doing is to reserve a larger space

play11:06

to store the same value with what

play11:09

which the optimization of resources is not

play11:11

so good if instead of declaring it as

play11:14

short then declared it as int

play11:17

Well, the program also works

play11:19

perfectly what happens then I will

play11:21

can you imagine this would be a

play11:23

byte statement this would be a

play11:25

statement of sun and this would be a

play11:27

statement of a and so we can follow it

play11:29

and in all cases so we're

play11:31

storing inside is the number

play11:33

35 in short then we would have

play11:36

served perfectly with a data of

play11:38

type b and a byte variable for

play11:41

do the test and you see that this

play11:43

it works effectively because we go back to

play11:44

press on the play as we have not saved

play11:47

changes we get the intermediate window

play11:48

click on ok

play11:50

effectively the program works

play11:51

exactly the same

play11:54

if we want to make a statement in the

play11:56

same line as we saw in your

play11:58

moment is to say instead of starting the

play12:01

variable and then sorry instead of

play12:03

declare the variable and then start it

play12:06

we can do everything in the same line

play12:09

that is, if we do without the

play12:11

initiation of variable and together with the

play12:14

statement we say fifth age equal

play12:16

to 35 semicolon, well, this is

play12:19

valid perfectly we are doing

play12:21

an initiation and declaration

play12:25

initiation of variables in it

play12:26

line many times then you can do it

play12:29

well to simplify the code but

play12:31

other times not because he declares is a

play12:33

variable and you do not know for sure what

play12:35

value will take that variable in the

play12:38

future

play12:39

the variable name says it all and it is

play12:41

that the value stored inside

play12:44

it can vary and there comes the name of

play12:46

variable can change is to say that if

play12:47

after declaring a variable and

play12:49

after starting it as we have

play12:51

we in this code later on will

play12:55

we changed the value saying it was

play12:56

equal to 75 as this is perfectly

play12:59

valid because it is a variable and

play13:02

in the definition that we saw in the video

play13:03

earlier we said that a variable

play13:05

memory space where it is stored

play13:07

a value that can change during the

play13:10

execution of a program if we execute

play13:13

this code then what will come out of us

play13:15

console is number 75 because all the

play13:19

java programs start to run by

play13:21

the main method right now is very

play13:23

simple because we have nothing nothing is

play13:25

that a main method when we create

play13:27

more complex applications you will discover

play13:29

that we have applications formed by

play13:31

several classes formed with a lot of

play13:33

methods but there's always going to be a

play13:35

main method in one of those classes

play13:38

because the code of that application always

play13:40

begins to run within the method

play13:43

main and once the code

play13:45

the compiler or interpreter better said

play13:47

once the interpreter when he is

play13:49

running the program enters the

play13:51

main method this code starts at

play13:53

run from top to bottom then

play13:54

then the first line that interprets

play13:57

is to try equal to 35 but

play13:59

immediately after crushing on

play14:01

write the value saying that it is equal to

play14:02

75 and finally print

play14:06

with which good let's try it on

play14:08

this time I'm going to save changes with

play14:10

controls or by pressing the floppy disk and

play14:14

now if I press on the window

play14:15

intermediate should not go out and does not come out

play14:17

but fix as in the console as the

play14:19

value that gives me is 75 not if we

play14:22

this initiation this change of value what

play14:25

we do behind the point-to-point system

play14:28

print then this program works

play14:30

perfectly just that as the code

play14:32

inside the main method is executed from

play14:35

top to bottom first declares and starts

play14:37

the age variable then prints on the

play14:41

console the value that has age but the

play14:44

value that you have at this height of

play14:45

program that is 35 and after having

play14:48

taken out by console the 35 returns to

play14:50

assign a value that we do not see because it does not

play14:52

We are telling you to go back to

play14:53

include if we execute this code

play14:55

pressing on the play

play14:57

Well, we see that the value is really

play14:59

the 35 we could do to see the

play15:01

new value of the variable then another

play15:03

system point out point print remember

play15:07

that java is case sensitive what then

play15:10

must respect uppercase and lowercase

play15:15

well, once we've done this

play15:16

what is going to come out now in

play15:18

code console is executed from above

play15:20

down well, we are going to get the

play15:22

messages in console 1 and 2 because I have

play15:25

two instructions system point to point

play15:27

pin

play15:28

the first message would take away the value of

play15:31

the variable given this height of

play15:32

program the second as the value that

play15:34

age at that height of the program and

play15:35

just before we gave it a value

play15:38

different we have varied the value of the

play15:40

variable then then if we click on

play15:41

the play

play15:43

we have that effectively gives us both

play15:45

values the two system point out point

play15:47

print l

play15:49

to understand a little better the

play15:51

code although we still need a lot to

play15:53

understand it perfectly so I'll tell you

play15:56

that java is a programming language

play15:57

object oriented that means that

play16:00

in java everything is considered an object

play16:02

absolutely everything the console where

play16:06

we are seeing the results

play16:07

it is also considered by java a

play16:09

object and the objects and we'll talk about

play16:12

this carefully have properties and

play16:15

they have methods like in real life they do not

play16:17

the objects of real life a car a

play16:20

table

play16:22

a chair have properties of a table

play16:25

because it has a width a height a weight a

play16:28

color even a temperature all that

play16:30

they would be properties and also objects

play16:33

have methods is able to make a

play16:36

object that would be a method not

play16:38

for example a car the method that can

play16:41

have a car can be start braking

play16:42

turn to the left is turn to the

play16:44

right is to teach the methods of

play16:45

car object while the

play16:46

properties could be with dry the red

play16:48

with se blue color car width three

play16:52

meters high in 90 centimeters and so on

play16:57

well as the console is considered

play16:59

also an object has its properties

play17:01

and its methods is to say this little window and

play17:05

is what we are doing with this

play17:06

instruction that we have here what

play17:07

we are doing is neither more nor less

play17:08

that accessing or executing a method is

play17:12

say something that console window

play17:14

can do and one of the things that can

play17:16

do just like a car can turn

play17:18

start or stop one of the things that

play17:20

can do is print it or what you

play17:22

we are saying is that this object

play17:24

belonging to the system ie the

play17:27

console out of the system prints the age

play17:32

basically is this do not worry that

play17:34

this will be explained in detail in

play17:36

its moment

play17:38

as for the spaces that we can

play17:40

leave vertically as you can see

play17:42

they have no influence when it comes to

play17:45

execute a program that is to say the

play17:46

vertical spaces that we can leave

play17:48

between instructions well they do not have

play17:51

importance and in terms of

play17:52

comments this is extremely useful

play17:54

when we learn to program when

play17:57

we learn to program and we start

play17:59

build our first codes

play18:01

it helps a lot to go inserting

play18:03

comments throughout the code that

play18:05

help us understand a little more

play18:07

Well, everything we are doing for

play18:09

example would be a good practice since

play18:12

this is the first statement of

play18:13

variable that we have done include a

play18:15

comment to the right good so that

play18:17

indicate that that is a statement of

play18:19

initiation in the same line as

play18:21

include comments in java if the

play18:23

comments these personal notes

play18:26

they will be from a single line the

play18:28

comment has to be preceded by

play18:29

two slanted bars the symbol of

play18:31

divide and then the message that

play18:34

you want to put

play18:36

If the comment is going to be composed of

play18:38

several lines because it must start with

play18:40

disc bars

play18:42

the expression the comment you want

play18:45

put and end with asterisk bar

play18:48

in our case as we are going to include a

play18:50

comment of a single line just to

play18:52

continuation of the declaration

play18:53

initiation of the age variable

play18:55

we put two inverted bars and

play18:57

then we can put what we

play18:59

fancy as long as it occupies a

play19:00

single line declaration and initiation

play19:04

of variable in a single line not os

play19:10

you fear because the eclipse underlines us

play19:12

then some terms of these messages

play19:16

because when we go to execute

play19:18

interpreting the program will not have it in

play19:20

account since it is a comment then

play19:22

then here we have included our

play19:23

first comment more comments than

play19:25

we can include good because imagine that

play19:27

Now I want to include a message

play19:30

several lines just before the

play19:31

system instruction point by point print

play19:34

well disc bars and a

play19:36

then we would write the message and

play19:39

I'm going to do it in several lines because

play19:41

example we could put the following

play19:44

instruction

play19:47

print

play19:49

in the console

play19:51

and we can put here in parentheses to

play19:53

sister 1 out is the system console

play19:59

the message

play20:02

of the variable or better the value

play20:05

directly the value of the variable

play20:09

and since said that I'm going to put several

play20:11

lines of the variable age set as

play20:15

the

play20:16

comments because as soon as he has given

play20:18

enter to do it in several lines

play20:20

here, the eclipse alone has already

play20:23

built the comment close the

play20:26

intermediate asterisk really is not

play20:28

necessary although eclipse builds it is

play20:30

say this intermediate asterisk if not

play20:31

we want to erase does not happen absolutely

play20:33

nothing I do not know exactly why

play20:36

builds eclipse but good if it gets

play20:38

It does not bother you either and at the time of

play20:40

execute the program I keep changes then

play20:42

these comments do not affect at all

play20:44

to the good functioning of the program that

play20:46

the program continues to function as it should

play20:50

then then remember accustomed

play20:52

especially now that we are starting

play20:54

to program then include comments on

play20:57

all the lines that you want there is no

play20:58

limits in terms of putting comments and

play21:01

This does not imply that the program is going to

play21:02

go slower or weigh much more because it

play21:05

it's about text so good, so let's go

play21:07

to leave this video at the point where

play21:09

we meet and we will continue advancing

play21:11

in future deliveries so I invite you to

play21:13

Stay tuned until then

Rate This

5.0 / 5 (0 votes)

الوسوم ذات الصلة
ProgramaciónJavaCursoEclipseVariablesData TypesComentariosMétodosObjetosConsola
هل تحتاج إلى تلخيص باللغة الإنجليزية؟