PEQUEÑO EJEMPLO DE PRIMER PROGRAMA EN JAVALas palabras reservadas se pueden clasificar en las...

Preview:

Citation preview

PEQUEÑO EJEMPLO DE PRIMER

PROGRAMA EN JAVA

CREANDO UN NUEVO PROJECTO TENEMOS LO SIGUIENTE:

/**

* @(#)prueba.java

*

* prueba application COMENTARIOS

*

* @author

* @version 1.00 2012/5/18

*/

public class prueba { DEFINICION DE CLASE

public static void main(String[] args) { DEFINICION DE METODOS

// TODO, add your application code

System.out.println("Hello World!"); SENTENCIAS DEL METODO

}

}

NOTESE LA PLATILLA POR DEFAULT CUANDO SE CREA EL

PROYECTO

REGLAS PARA ELEGIR NOMBRES DE IDENTIFICADORES

int simple; // starts with alphabetic character

int _under; // starts with underscore

int more$money_is_2much; // may contain dollar signs, and/or

underscores, and/or

// digits, and/or alphabetic characters

NOMBRE INVALIDOS DE VARIABLES

int 1bad; // inappropriate starting character

int number#sign; // contains invalid

character

int foo-bar; // ditto

int plus+sign; // ditto

int x@y; // ditto

int dot.notation; // ditto

TIPOS, VARIABLES Y VALORES

NOMBRE

TIPO

RANGO

Las palabras reservadas se pueden clasificar en las

siguientes categorías:

Tipos de datos: boolean, float, double, int, char

Sentencias condicionales: if, else, switch

Sentencias iterativas: for, do, while, continue

Tratamiento de las excepciones: try, catch, finally, throw

Estructura de datos: class, interface, implements, extends

Modificadores y control de acceso: public, private,

protected, transient

Otras: super, null, this.

Recommended