Skip to content

Instantly share code, notes, and snippets.

// Escopo Global
var nome = "Robson";
jQuery('#modal').hide();
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
var MinhaBibliotecaGlobal = {
var nome = 'Robson';
var escopo1 = function () {
// nome é visível aqui
var escopo2 = function () {
// nome é visível aqui também
var escopo3 = function () {
// nome também é visível aqui
};
};
};
function foo(a) {
//var a = 2; //é como se a estivesse no escopo de foo
var b = a * 2;
function bar(c) {
//var c = b * 3; //é como se c estivesse no escopo de bar
console.log( a, b, c );
}
bar( b * 3 );
}
foo( 2 ); // 2, 4, 12
public class Cliente {
private Date dataCriacao;
public Date getDataCriacao() {
return this.dataCriacao;
}
}
Cliente cli = new Cliente();
import java.time.*;
public class InstantTeste {
public static void main(String args[]) {
Instant t1 = Instant.now();
System.out.println(t1);
Instant t2 = t1.plusSeconds(10);
System.out.println("T1 + 10s: " + t2);
Instant t3 = t2.minusSeconds(10);
System.out.println("T2 - 10s: " + t3);
public class TempoExecucao() {
public static void main(String args[]) {
Long t1 = System.currenttimemillis();
metodoDemorado();
Long t2 = System.currenttimemillis();
Long tempo = (t2-t1)/1000;
System.out.println("Tempo total: " + tempo);
}
public class TempoExecucao() {
public static void main(String args[]) {
Instant inicio = Instant.now();
metodoDemorado();
Instant fim = Instant.now();
Duration tempoTotal = Duration.between(inicio, fim);
long millis = tempoTotal.toMillis();
long min = tempoTotal.toMinutes();
long sec = tempoTotal.getSeconds(); //foge o padrão :)
}
import java.time.*;
public class Durations {
public static void main(String[] args) {
//Meu algoritmo padrão rodou em 5000 milisegundos
Duration algoritmo1 = Duration.ofMillis(5000);
Instant t1 = Instant.now();
algoritmo2();