You are on page 1of 2
lwww.youtube.com/c/ProgramacionDesdeCero| BEN EV Oiutcaesfasreleal liaites Metals) Casa acces elit ea UN boolean = true/false yy * = SUM igual && “y" logico int = 10 tee distinto I] “0” légico float = 4.75 multiplicacién > mayor 1 negacién légica double = 1.0002 en < menor Y ‘% — médulo mayor 0 igual ++ incremento en 1 oaner niga = decremento en 1 Sey WU Site Cre) RUA seabed class Main { public static void main(String[] args) { //cédigo } DECLARACION Come rasio; — ASIGNACION i) eats) ‘OBJETO NECESARIO PARA LEER DATOS DE TECLADO import java.util.Scanner; Scanner entrada=new Scanner (System. in); LEER Y GUARDAR UN STRING INGRESADO POR EL USUARIO Sines ‘String nombresentrada.next()5 CONCATENAR LEER Y GUARDAR UN NUMERO INGRESADO POR EL USUARIO “Hola "+ "mundo ) |) [int edad-entrada.nextint (); ) OBTENER LONGITUD IMPRIMIR (MOSTRAR) DATOS (Ceia™teneth) ‘System.out.printIn("Hola, mundo"); } CARACTER POSICION 0 IMPRIMIR MAS DE UN VALOR ("masica"[o] ) ‘System. out.print1n("Tu edad es "+edad); ) ‘COMPARAR strA.equals(strB) ead SIMPLES (DOS POSIBILIDADES) int opcion; do { SIEMENS CONDICIONALES (0 0 MAS REPETICIONES) String nombre = entrada.next(); while (Inombre.equals("Luis")) { System.out.println("Este no es Luis"); nombre = entrada.next(); } CONDICIONALES (1 0 MAS REPETICIONES) opcion = entrada.nextInt(); } while (opcion < 1 || opcion > 5); Ce |Programacién} MDesde Cero int nsentrada.nextInt()3 if (n==9) { System.out.print1n("jGanaste!"); } €18§sfem.out.print1n("No adivinaste"); } MULTIPLES (MAS DE DOS POSIBILIDADES) int opcion=entrada.nextInt(); switch (opcion) { case 1: System.out.printIn("1"); break; case 2: System.out.printIn("2"); break; default: System.out.println("Ni 1 ni 2"); } ‘else y default son opcionales DECLARAR E INICIALIZAR ‘int Al]=(1,2,3}5 int B[]=new int[100]; int({]{] C={ {1,2,3,4}, {5,6,7} }5 ACCEDER AL ELEMENTO EN LA POSICION S B[5]=100; jwww.youtube.com/c/ProgramacionDesdeCero| JAVA * huja de referencia: POO TEU RAs Oar; MODIFICADORES DE ACCESC Gass Estudiante { public clase, paquete, subclase, resto del programa private String nonbre; protected clase, paquete, subclase private int legajo; sin modificador clase, paquete public Persona(String nombre, int nLeg) peta as 1/cédigo GETTER public int getLegajo(){ DECLARACION return this. legajo; Estudiante juan; INSTANCIACION 285") 5 public void setLegajo(int nLeg){ juansnew Estudiante(" juan this. legajo=nLeg; aS: } ATRIBUTOS DE CLASE (static string escuela; I aruauos rinat METODOS DE CLASE (private final long dni = 39243612; ___) su contenido no puede variar. Sies un objeto, no puede static void darNombreAEscuela(String n) { cambiar la referencia, pero si el estado del objeto referenciado. Estudiante.escuela=n3 METODOS FINAL INVOCAR METODO DE CLASE ; . i private final calcularPromedio() { } Estudiante.darNombreaéscuela("ABC"); ieogiraal ni Nanas por EnCana no se requiere una instancia del objeto para utilizarios. CLASES FINAL tun método static no puede usar atributos no static. public finallclass AstenaturaHay ‘no pueden ser heredadas (pero si instanciadas). CLASE ABSTRACT public abstract class Personal { } no pueden ser instanciadas (s6lo heredadas). ‘com Oren eT pccaso] pares | Pennae [Pom] ma state cave-vaorauptcadod AO" METODOS ABSTRACT elementos} los [asset v public abstract double calcularSalario()5, cA ‘no pueden ser implementados (lo hace la clase hi public interface Empleado { Programacién| Minocde Cercle

You might also like