interface DBObject {
DBObject initializeIdAndName(long id, String name);
}
static class User implements DBObject {
long id;
String name;
public User initializeIdAndName(long id, String name){
this.name = name;
this.id = id;
return this; //<--- warum return this?
}
@Override
public String toString() {
return String.format("Der Name des Benutzer ist %s, ID = %d", name, id);
}
}
hidden #10625598
Level 23
wie werden mit %d und %s die namen erkannt? es ist ja ein geschlossener String? und was bedeutet einfach return this bzw was returnt er und warum hat man das vorher nie gebraucht?
Gelöst
Kommentare (1)
- Beliebt
- Neu
- Alt
Du musst angemeldet sein, um einen Kommentar schreiben zu können
Gellert Varga
1 Juni 2020, 19:27
String.format() method:
%s represents an argument, that must be a string
%d represents an argument, that must be a decimal
%1$s represents the first argument, that must be a string
%2$s represents the second argument, that must be a string
%3$d represents the third argument, that must be a decimal
OUTPUT:
ABC und ABC + XYZ + 158

+3