This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use (groovy.time.TimeCategory) { | |
//Example of Add Date 20 days from now | |
println new Date() | |
println 20.days.from.now | |
//Example of Add Date 3 months from now | |
println new Date() | |
println 3.months.from.now | |
//Example of Add Date 2 years from now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Estado { | |
List<String> posicoes | |
int nome | |
Estado pai | |
static constraints = { | |
pai nullable: true | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TesteIR2 { | |
public static void main(String[] args) { | |
// De 1900.0 até 2800.0 o IR é de 7.5% e pode deduzir R$ 142 | |
// De 2800.01 até 3751.0 o IR é de 15% e pode deduzir R$ 350 | |
// De 3751.01 até 4664.00 o IR é de 22.5% e pode deduzir R$ 636 | |
double salario = 3800.0; | |
if (salario >= 1900.0 && salario <= 2800.0) { | |
System.out.println("A sua aliquota é de 7%"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestWhile { | |
public static void main(String[] args) { | |
int count = 0; | |
while (count <= 10) { | |
System.out.println(count); | |
count++; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestaLaco2 { | |
public static void main(String[] args) { | |
for (int linha = 0; linha < 10; linha++) { | |
for (int coluna = 0; coluna <= linha; coluna++) { | |
System.out.print("*"); | |
} | |
System.out.println(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestaLacos { | |
public static void main(String[] args) { | |
for (int multiplicador = 1; multiplicador <= 10; multiplicador++) { | |
for (int contador = 0; contador <= 10; contador++) { | |
System.out.print(multiplicador * contador); | |
System.out.print(" "); | |
} | |
System.out.println(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestFor { | |
public static void main(String[] args) { | |
for (int count = 0; count <= 10; count++) { | |
System.out.println(count); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TestaEscopo { | |
public static void main(String[] args) { | |
System.out.println("testando condicionais"); | |
int idade = 20; | |
int quantidadePessoas = 3; | |
boolean acompanhado = false; | |
if (quantidadePessoas >= 2) { | |
acompanhado = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultiplosDeTresAteCem { | |
public static void main(String[] args) { | |
for (int i = 3; i < 100; i += 3) { | |
System.out.println(i); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Fatorial { | |
public static void main(String[] args) { | |
int fatorial = 1; | |
for (int i = 1; i < 11; i++) { | |
fatorial *= i; | |
System.out.println("Fatorial de " + i + " = " + fatorial); | |
} | |
} | |
} |