Skip to content

Instantly share code, notes, and snippets.

@mquezada
Last active August 29, 2015 13:57
Show Gist options
  • Save mquezada/9600798 to your computer and use it in GitHub Desktop.
Save mquezada/9600798 to your computer and use it in GitHub Desktop.
// se puede importar toda la libreria
import java.io.*;
// o solo algo especifico
import java.io.IOException;
// la clase debe tener el mismo nombre del archivo
class MiPrograma {
// los comentarios se escriben con // o entre
/* slash y
asterisco */
// este es la funcion que se llamara al ejecutar el programa
static public void main(String[] args) throws IOException {
// variables
int a = 1;
String s = "mi string";
boolean condicion = true;
// condicionales
if(condicion) {
// iteraciones
while(1 < 2) {
System.out.print("este string no termina en salto de linea ");
break; // rompe el ciclo
}
for(int i = 0; i < 5; i++) { // equivalente a "for i in range(100)"
// i++ es igual a "i = i + 1", o i += 1
System.out.println("este string si termina en salto de linea");
}
}
// y por si no lo han notado, la indentacion no es obligatoria,
// y cada instruccion debe terminar en ; o con { }
System.out.println("Hola");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment