GetClass aramak için nasıl() Java'da statik bir yöntem? | Netgez.com
SORU
26 Kasım 2011, CUMARTESİ


GetClass aramak için nasıl() Java'da statik bir yöntem?

Bazı statik yöntemler gereken bir Dersim var. Yöntem getClass aramam gerek bu statik yöntemler içinde() aşağıdaki çağrı yapmak için:

public static void startMusic() {
  URL songPath = getClass().getClassLoader().getResource("background.midi");
}

Ancak Eclipse söyledi:

Cannot make a static reference to the non-static method getClass() 
from the type Object

Bunu düzeltmek için uygun bir yol, bir derleme zamanı hatası nedir?

CEVAP
26 Kasım 2011, CUMARTESİ


Sadece kullanım TheClassName.class yerine getClass().

Bunu PaylaÅŸ:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • AmeriiK_HD

    AmeriiK_HD

    16 AÄžUSTOS 2012
  • Excel Functions

    Excel Functi

    4 NİSAN 2010
  • Rozetked | Обзоры

    Rozetked | Ð

    5 AÄžUSTOS 2011

İLGİLİ SORU / CEVAPLAR