Mostrando entradas con la etiqueta java. Mostrar todas las entradas
Mostrando entradas con la etiqueta java. Mostrar todas las entradas

martes, 20 de agosto de 2013

Método que devuelve invertido un arreglo JAVA Object[]

Método que recibe un Object[] y devuelve invertido.

    public static Object[] reverseArray(Object[] a) {
        /*
          Please implement this method to
          return a new array where the order of elements has been reversed from the original
          array.
         */
        Object r[] = new  Object[a.length];
        int j = a.length-1;
        for(int i=0; i <=a.length-1; i++){
           
            r[i] = a[j];
            j--;   
        }
    return r;
    }

Este es el método principal que llama al que invierte.
/**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
       
       Object[] ar =  new String[]{"A","B","C"};
       Object[] res = reverseArray(ar);  
      
       for(int i = 0; i <= res.length-1;i++){
           System.out.println("= "+res[i]);
       }
      
    }

jueves, 23 de mayo de 2013

Calculadora Binaria en Java



Calculadora de números binarios en Java, y conversiones de sistemas numéricos.



Interfaz de operaciones

 

Interfaz de conversiones

 DESCARGAR CÓDIGO
OTRO LINK