WRAPPERS

package logic;

import javax.swing.JOptionPane;

public class Wrappers {

public static void main(String[] args) {

Integer i1 = new Integer(42);
Integer i2 = new Integer ("42");
Float f1=new Float(13.6f);
Float f2=new Float("13.6f");
JOptionPane.showMessageDialog(null, i1.doubleValue());
JOptionPane.showMessageDialog(null,i1.toString());
JOptionPane.showMessageDialog(null,i1.floatValue());
JOptionPane.showMessageDialog(null,i1.byteValue());

JOptionPane.showMessageDialog(null,f1.isInfinite());
JOptionPane.showMessageDialog(null,f1.toString());
JOptionPane.showMessageDialog(null,f1.floatValue());
JOptionPane.showMessageDialog(null,f1.byteValue());
Boolean b = new Boolean ("false");
if (b){
}
Integer d2 = Integer.valueOf("101011", 2);
Integer j2 = new Integer(42);                                                                                                                                                                                                                                              
byte b1 = j2.byteValue();      
short s = j2.shortValue();    
double d = j2.doubleValue();
System.out.println( d2+" "+j2+" "+b1+" "+s+"  "+d);
double d4 = Double.parseDouble("3.14");
System.out.println("d4 = " + d4);  

Double d5 = Double.valueOf("3.14");
System.out.println(d5 instanceof Double);
long L2 = Long.parseLong("101010", 2);
System.out.println("L2 = " + L2);  

Long L3 = Long.valueOf("101010", 2);  
System.out.println("Valor de L3 = " + L3);
Double da = new Double("3.14");
System.out.println("d = " + da.toString() );
String s3 = Integer.toHexString(254);
System.out.println("254 es " + s3);    

String s4 = Long.toOctalString(254);  
System.out.println("254(oct) = " + s4);

}

}

No hay comentarios:

Publicar un comentario