Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature may not be available in some browsers.
Auf jedem Typ, oder nicht?Die gibt es implizit auf jedem Referenztyp, um das java.lang.Class Objekt zu bekommen, welches diesen Referenztyp als Laufzeitobjekt repräsentiert.
int.class oder void.class sind ja auch korrekt.import java.awt.Point;
public class JavaIsAlwaysCallByValue {
static void clear( Point p ) {
System.out.println( p ); // java.awt.Point[x=10,y=20]
p = new Point();
System.out.println( p ); // java.awt.Point[x=0,y=0]
}
public static void main( String[] args ) {
Point p = new Point( 10, 20 );
clear( p );
System.out.println( p ); // java.awt.Point[x=10,y=20]
}
}
static void clear( Point p ) {
p.x = p.y = 0;
}
static Point clearObj(Point p) {
p.x = p.y = 0;
return(p);
}
public static void main(String[] args) {
Point p = new Point(10,20);
p = clearObj(p);
System.out.println(p);
}
Wenn Du mir Dein Sparschwein des TypsWarum wird p (die ich in der main-Methode erzeugt habe) beim Aufruf von clear(p) verändert, wenn die Methode clear(p) nur void ist und keine Rückgabe liefert...
class Sparschwein {
int inhalt;
}
public void leere(Sparschwein s) {
s.inhalt = 0;
}