inline classes

M

Mize-ze

Hi,
I remember that I saw a code somewhere that sends an inline class as an
argument but for some reason I cant find any examples now when I
search for it on the web.

It looked something like that:

String files[] = xmlpath.list(
new class myFilter implements java.io.FilenameFilter
{
//Overriden method
public boolean accept(File dir,String name)
{
if
(dir.getAbsolutePath().equals(xmlRuleProvider.XMLPATH.toString())&&
name.endsWith(".xml") )
return true;
else
return false;
}

} //end of class decleration and (hopefully) instansiating
);


But the above code does not compile,
can someone refer me to a good example?

Thanks.
 
Y

Ye Dafeng

Mize-ze said:
Hi,
I remember that I saw a code somewhere that sends an inline class as an
argument but for some reason I cant find any examples now when I
search for it on the web.

It looked something like that:

String files[] = xmlpath.list(
new class myFilter implements java.io.FilenameFilter
~~~~
I think the "class" is redunant
 
R

Robert Klemme

Hi,
I remember that I saw a code somewhere that sends an inline class as an
argument but for some reason I cant find any examples now when I
search for it on the web.

It looked something like that:

String files[] = xmlpath.list(
new class myFilter implements java.io.FilenameFilter
{
//Overriden method
public boolean accept(File dir,String name)
{
if
(dir.getAbsolutePath().equals(xmlRuleProvider.XMLPATH.toString())&&
name.endsWith(".xml") )
return true;
else
return false;
}

} //end of class decleration and (hopefully) instansiating
);


But the above code does not compile,
can someone refer me to a good example?

Thanks.

Thread t = new Thread( new Runnable() {
public void run() {
System.out.println("hello world");
}
} );

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top