non static variable

Hi,

I am a newbie to this forum , I am currently trying to build an audio player application using java and javaLayer decoder , but I keep getting an error saying ............

non-static variable playlist cannot be referenced from a static context

mp3File = (MpegInfo) PlaylistManager.playlist.get(position);

any ideas ?

cheers

[380 byte] By [geraghty] at [2007-9-30 3:46:52]
# 1
Create an instance of PlaylistManager and refer to playlist through it:PlaylistManager mgr = new PlaylistManager();... = mgr.playlist.get();
eriklindquist at 2007-6-29 15:00:04 > top of Java-index,Security,Event Handling...
# 2

it probably mean that you have declare you variable rmp3File as a non-static variable and your method is a static method

class Demo{

private String testing = "testing out "

public static void log(Object obj){

System.out.println(strTest + obj.toString()); // error here..."StrTest" is non-static and cannot be used in a static method

}

}

to handle the error you can

1. make strTest a static variable eg) private static strTest = "testing out ";

2. or make the method non-static:public void log(Object obj){ ... }

3. as mentioned above post..create a local variable inside the static method

public void log(Object obj){

String strTest = "testing";

System.out.println(strTest + obj.toString());

}

note: when you declare a method "static" the method is shared among all instance of the class

tnguyen1973 at 2007-6-29 15:00:04 > top of Java-index,Security,Event Handling...
# 3
oops private String testing = "testing out ";should have been private String strTesting = "testing out ";
tnguyen1973 at 2007-6-29 15:00:04 > top of Java-index,Security,Event Handling...