![]() |
Kann jemand Java?
Hallo Leute
mal eine ungewöhnliche Frage: warum gibt dieser Javacode einen Fehler:
Code:
Eigentlich sollte bloß eine Klasse ("tester) mit zwei Funktionen erstellt werden.
public class java1
{ public class tester { private int i; public void seti(int r) { this.i = r; } public int geti() { return this.i; } } public static void main (String[] args) { tester t1,t2; t1 = new tester(); t1.seti(150); } } Der Compilter mault
Code:
Weiß jemand schnell Rat?
non-static variable cannot be referenced from a static context!
Danke TheOmega |
Re: Kann jemand Java?
versuch mal die main ausserhalb der Klasse zu implementieren.
grüße, daniel |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:50 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz