From e71ebe2c8986c9c69557f2a2cd8d1fc7f0a638d3 Mon Sep 17 00:00:00 2001 From: SalatielGenol Date: Sat, 15 Oct 2022 08:14:41 +0200 Subject: [PATCH] Constantes y comienzo con operadores --- java.md | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/java.md b/java.md index 43fccd6..e282f95 100644 --- a/java.md +++ b/java.md @@ -14,7 +14,7 @@ */ ``` -#### Declaración e inicialización de variables +#### Variables Se debe fijar el tipo de variable en su declaración, y opcionalmente inicializarla en otra parte del código. @@ -32,4 +32,34 @@ Tan solo en variables locales se puede usar la inferencia de tipos, en la cual s ```java var nombreVariable = valor; -``` \ No newline at end of file +``` + +#### Constantes + +```java +final tipo nombreConstante = valor; +final var nombreConstante = valor; +``` + +#### Operadores + +Aritméticos + + | Operación | Signo | Uso | Resultado | + | -------------- | ----- | ------- | --------- | + | Suma | + | a=5,b=5 | a+b=10 | + | Resta | - | a=5,b=5 | a-b=0 | + | Multiplicación | * | a=5,b=5 | a*b=25 | + | División | / | a=5,b=3 | a/b=1 | + | Módulo | % | a=5,b=3 | a%b=2 | + +Unarios + + | Operación | Signo | Uso | Resultado | + | --------------- | ----- | ------ | --------- | + | Cambio de signo | - | a=-1 | -a=1 | + | Convierte a int | + | a=F | +a=70 | + | Complemento a 1 | ~ | a=1 | ~a=-2 | + | Decremento | -- | a=5 | --a=4 | + | Incremento | ++ | a=5 | ++a=6 | + | Negación lógica | ! | a=true | !a=false | \ No newline at end of file