Skip to content

Instantly share code, notes, and snippets.

View maurcarvalho's full-sized avatar
🏠
Working from home

Mauricio Carvalho maurcarvalho

🏠
Working from home
View GitHub Profile
static void insertionSort(int[] ar) {
//variavel responsavel por conter o valor do ultimo indice.
int lastIndex;
//variavel auxiliar para conter o valor do elemento corrente.
int key;
for(int j = 1; j < ar.length; j++){
//atribuindo valor elemento corrente.
@maurcarvalho
maurcarvalho / gist:8237720
Created January 3, 2014 13:19
Listas e Collections
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class ExemploLista {
public static void main(String[] args) {
@maurcarvalho
maurcarvalho / gist:8237827
Last active January 2, 2016 02:29
Output
Output:
2, 4, 8, 12, 15, 19, 21, 24, 26, 29, 30, 32,
35, 36, 41, 44, 49, 52, 57, 58, 59, 64, 65,
68, 73, 77, 80, 82, 85, 88, 93, 97, 101, 101,
105, 108, 111, 115, 118, 122, 127, 130, 131, 132,
134, 135, 136, 138, 141, 144, 146, 151, 153, 158,
160, 165, 169, 171, 176, 179, 184, 187, 190, 194,
197, 200, 205, 210, 215, 217, 222, 225, 230, 231,
236, 239, 243, 244, 246, 248, 253, 254, 256, 258,
@maurcarvalho
maurcarvalho / gist:8238098
Created January 3, 2014 13:45
Interface Veiculo - Array Interface
public interface Veiculo {
void andar();
void ligar();
void desligar();
}
@maurcarvalho
maurcarvalho / gist:8238106
Created January 3, 2014 13:46
Classe Carro
public class Carro implements Veiculo {
public void andar() {
System.out.println("Carros andam em rodovias");
}
public void ligar() {
System.err.println("Ligar com partida a combustão");
@maurcarvalho
maurcarvalho / gist:8238119
Created January 3, 2014 13:47
Motocicleta
public class Motocicleta implements Veiculo {
public void andar() {
System.out.println("Motos andam em rodovias");
}
public void ligar() {
System.err.println("Ligar com partida a combustão");
@maurcarvalho
maurcarvalho / gist:8238132
Created January 3, 2014 13:47
Teste Interface
public class TesteInterface {
public static void main(String[] args) {
// Array de Objetos que implementam a interface Veiculo
Veiculo[] arrayDaInterface = new Veiculo[] { new Motocicleta(),
new Carro() };
Carro c = new Carro();
// Aqui preciso garantir que na posição 1 terá um carro utilizando um CAST , pois varias classes podem implementam veiculo e pertencer a este array e nao somente um Carro.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
Define value for property 'groupId': : br.com.mcarvalho.wsclient
Define value for property 'artifactId': : sample-project
Define value for property 'version': 1.0-SNAPSHOT: :
Define value for property 'package': br.com.mcarvalho.wsclient: :
Após isso será solicitado a confirmação, digite Y (yes)
Confirm properties configuration:
groupId: br.com.mcarvalho.wsclient
artifactId: sample-project
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Old (1.x) Archetype: vraptor-archetype-webapp-blank:0.1.0
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: br.com.mcarvalho.wsclient
[INFO] Parameter: packageName, Value: br.com.mcarvalho.wsclient
[INFO] Parameter: package, Value: br.com.mcarvalho.wsclient
[INFO] Parameter: artifactId, Value: sample-project
[INFO] Parameter: basedir, Value: C:\Users\mauriciosantos\Documents\GitHub\ws-client
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] project created from Old (1.x) Archetype in dir: C:\Users\mauriciosantos\Documents\GitHub\ws-client\sample-project