In un altro esercizio di Bruce Eckel, il codice che ho scritto utilizza un metodo e cambia valore in un'altra classe. Ecco il mio codice:Java: double vs float
class Big {
float b;
}
public class PassObject {
static void f(Letter y) {
y.c = 'z';
} //end f()
static void g(Big z) {
z.b = 2.2;
}
public static void main(String[] args) {
Big t = new Big();
t.b = 5.6;
System.out.println("1: t.b : " + t.b);
g(x);
System.out.println("2: t.b: " + t.b);
} //end main
}//end class
Si sta generando un errore che dice "Possibile perdita di precisione".
PassObject.java:13: possible loss of precision
found: double
required : float z.b = 2.2
passobject.java:20: possible loss of precision
found : double
required : float t.b = 5.6
Non può double
s essere float
s come bene?
grazie in anticipo
aggiungendo la "f" risolto. Grazie! – phill