Java: Doppel gegen Float

In einem anderen Bruce Eckel übung, den code, den ich geschrieben habe, braucht eine Methode und ändert den Wert in eine andere Klasse. Hier ist mein code:

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

Es wirft eine Fehlermeldung "Possible loss of precision."

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

Nicht doubles floats?

vielen Dank im Voraus

InformationsquelleAutor der Frage phill | 2009-04-24

Schreibe einen Kommentar