Administra tu Blog

¡Crea tu Blog Ya! Fácil y Gratis

Java ORACLE
Welcome!. Gracias por ingresar, espero guste.

Archivo: Diciembre 2008

17/12/2008 GMT 1

Sorteo JAVA

paulonline @ 17:36

En esta oportunidad les ofrezco el código de un programa para sortear elementos String:

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.List;
import java.util.Random;

public class SorteoRandom{
public static void main(String[] args) {
try{
String[] exp=new String[11];
exp[0]="10323243324";
exp[1]="10432434213";
exp[2]="10432424244";
exp[3]="20432647774";
exp[4]="10286267589";
exp[5]="10792476654";
exp[6]="20268890355";
exp[7]="10268980254";
exp[8]="10757999785";
exp[9]="20653878687";
exp[10]="20646376576";

int tot_exp=exp.length;
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
System.out.println("Total de expedientes: "+tot_exp);
System.out.println("Ingrese numero:");
String bar=br.readLine();
int foo=Integer.parseInt(bar);
System.out.println("Expedientes: ");

Hashtable ht=new Hashtable();
for(int i=0;i ht.put(i,exp[i]);
System.out.println(ht.get(i));
}
System.out.println("El numero es: "+foo);
System.out.println("Los resultados del sorteo son:");
for(int i=0;i Random r=new Random();
ht.put(i,exp[r.nextInt(tot_exp)]);
System.out.println(i+1+". "+ht.get(i));
}
}
catch(IOException ioe){
ioe.getMessage();
}
}

}

06/12/2008 GMT 1

La Potencia de Java

paulonline @ 17:03

Quiero decir que si no te sale un programa,

utiliza un try catch,

si no funciona con el try catch

en el catch, escribe tu programa

si no funciona con el try catch

jajaja

Java hace su aparición

utiliza un finally

y pon allí tu programa

...funcionará

Java

Contactar con la autora o autor | Archivo | ¡Crea tu Blog Ya! Fácil y Gratis