EXAMPLE 1CODEfor(int x = 0; x < 10; ++x){ System.out.print(x + " ");}OUTPUT0 1 2 3 4 5 6 7 8 9EXAMPLE 2CODE//NOTE that i'm using printlnfor(int x = 0, k=3; x < 10 && k > 0; x++, k-=1){ System.out.println(x + " " + k);}OUTPUT0 31 22 1EXAMPLE 3CODE//NOTE that i'm using println for(int x = 0, k=3; x < 10 && k > 0; x++, k-=1){ System.out.println(x + " " + k); } OUTPUT0 3 1 2 2 1EXAMPLE 4CODEfor( /*declaration*/ ; /*run condition*/ ; /*what happens after loop*/){ //yes... it causes an infinite loop System.out.println("Loop");}OUTPUTLoopLoopLoop(...) ...forever... (...)EXAMPLE 5CODEfor(int k=0; k <= 5; k++){ for(int y=0; y<=3; y++){ System.out.printf("\nOuter: %d Inner:%d", k, y); continue; //nothing happens... this continue refers the inner FOR } }OUTPUTOuter: 0 Inner:0Outer: 0 Inner:1Outer: 0 Inner:2Outer: 0 Inner:3Outer: 1 Inner:0Outer: 1 Inner:1Outer: 1 Inner:2Outer: 1 Inner:3Outer: 2 Inner:0Outer: 2 Inner:1Outer: 2 Inner:2Outer: 2 Inner:3Outer: 3 Inner:0Outer: 3 Inner:1Outer: 3 Inner:2Outer: 3 Inner:3Outer: 4 Inner:0Outer: 4 Inner:1Outer: 4 Inner:2Outer: 4 Inner:3Outer: 5 Inner:0Outer: 5 Inner:1Outer: 5 Inner:2Outer: 5 Inner:3EXAMPLE 6CODEfor(int k=0; k <= 5; k++){ for(int y=0; y<=3; y++){ System.out.printf("\nOuter: %d Inner:%d", k, y); break; //every time the code enters here, the inner FOR take a break. } }OUTPUTOuter: 0 Inner:0Outer: 1 Inner:0Outer: 2 Inner:0Outer: 3 Inner:0Outer: 4 Inner:0Outer: 5 Inner:0EXAMPLE 7CODE//this is a label for the outer FORRepeatSpeed:for(int k=0; k <= 5; k++){ for(int y=0; y<=3; y++){ System.out.printf("\nOuter: %d Inner:%d", k, y); continue RepeatSpeed; //this CONTINUE is similar to a simple break (in THIS POSITION, SPECIFICALLY). //This line means: "please, continue the for with label "RepeatSpeed"... NOW! // Go there immediately..." } }OUTPUTOuter: 0 Inner:0Outer: 1 Inner:0Outer: 2 Inner:0Outer: 3 Inner:0Outer: 4 Inner:0Outer: 5 Inner:0EXAMPLE 8CODERepeatSpeed:for(int k=0; k <= 5; k++){ for(int y=0; y<=3; y++){ System.out.printf("\nOuter: %d Inner:%d", k, y); break RepeatSpeed; //This line means: "please, break the FOR with label RepeatSpeed... NOW!!!" } }OUTPUTOuter: 0 Inner:0 For printing information on Console, you may use some methods present inside System.out. Let s learn a bit about them:System.out.print()Simply prints a line.SAMPLE USAGE:System.out.print("Java Imediato");System.out.print("blog wordpress");System.out.print(99);SAMPLE OUTPUT:Java Imediatoblog wordpress99System.out.println()Prints a line and perform a breakline in the end.SAMPLE USAGE:System.out.println("Java Imediato");System.out.println("blog blogspot");System.out.println(26);SAMPLE OUTPUT:Java Imediatoblog blogspot26System.out.printf()If you used to print with format in other languages, you also can do it in Java.SAMPLE USAGE: String name = "Andre"; int age = 28; float weight = 75.643f; System.out.printf("My name is %s. I'm %d years old and my weight is %.2f KG",name,age,weight);SAMPLE OUTPUT:My name is Andre. I'm 28 years old and my weight is 75.64 KG Os metodos sao as acoes de uma classe. Ate agora criamos metodos apenas para exibir mensagens no Console, e utilizamos alguns metodos ja prontos de outras classes, como o nextInt() da classe Scanner, por exemplo. Neste Post vamos aprender um pouco mais sobre as estruturas dos metodos e como realizar calculos matematicos simples dentro dos metodos.Estrutura basica de declaracao de um metodoMODIFICADOR DE ACESSO TIPO DO RETORNO IDENTIFICADOR (PARAMETROS)Observe esta declaracao do metodo imprimir():public void imprimir(){ //seus comandos de impressao}public: e um dos quatro modificadores de acesso existentes na linguagem Java. Falaremos sobre modificadores de acesso em Posts