Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

inline classes

Thread view: 
Mize-ze - 16 Nov 2006 13:08 GMT
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.
Ye Dafeng - 16 Nov 2006 13:14 GMT
> Hi,
> I remember that I saw a code somewhere that sends an inline class as an
[quoted text clipped - 5 lines]
> String files[] = xmlpath.list(
>              new  class myFilter implements java.io.FilenameFilter
           ~~~~
            I think the "class" is redunant

>              {
>                         //Overriden method
[quoted text clipped - 15 lines]
>
> Thanks.
Robert Klemme - 16 Nov 2006 13:34 GMT
> Hi,
> I remember that I saw a code somewhere that sends an inline class as an
[quoted text clipped - 24 lines]
>
> Thanks.

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

    robert
Oliver Wong - 16 Nov 2006 13:59 GMT
> 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.

   Try using the keywords "java anonymous class" (which gave me
http://www.developer.com/java/other/article.php/3300881) and "java local
inner class" (which gave me
http://www.javaworld.com/javaworld/javaqa/2000-03/02-qa-innerclass.html)

   - Oliver


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.