Hallo,
könnte mir jemand sagen, was dieser Code macht?
public class Euro {
private double amount;
public Euro(double amount) {
this.amount = amount;
}
public double getAmount() {
return this.amount;
}
}
Danke & Lg
Hallo,
könnte mir jemand sagen, was dieser Code macht?
public class Euro {
private double amount;
public Euro(double amount) {
this.amount = amount;
}
public double getAmount() {
return this.amount;
}
}
Danke & Lg
Hey.
// Eine Klasse namens 'Euro'.
public class Euro {
// Eine Instanzvariable, die einen Wert speichert.
private double amount;
// Konstruktor der Klasse 'Euro'. Ihm wird ein
// Initialwert übergeben und in der Instanzvariable 'amount'
// gespeichert.
public Euro(double amount) {
this.amount = amount;
}
// Gibt den gespeicherten Wert in 'amount' zurück.
public double getAmount() {
return this.amount;
}
// Mehr macht die Klasse nicht :wink:
}
Viel Erfolg noch,
Chris
Auch hallo.
könnte mir jemand sagen, was dieser Code macht?
So ganz ohne Kontext (JDO, Hibernate,…) ist das etwas schwieriger, aber machbar:
public class Euro {
//öffentliche Klasse Euro anlegen
private double amount;
// Variable amount anlegen, Datentyp double
public Euro(double amount) {
this.amount = amount;
}
//Konstruktor Euro mit impliziten Verweis auf amount
public double getAmount() {
return this.amount;
//Getter-Methode für Amount definieren
}
}
mfg M.L.