• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Public Class in a source file

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why should a public class be in a source file having the same name as it is having?
Is it because of Access specification?
saint4u@hotpop.com

Nothing is impossible!

 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is just a requirement enforced by many Java
compilers (javac included) ; it's not part of the
language definition. It allows the compiler to find
classes that it may need to compile while it's in
the process of compiling another class.
[ July 14, 2003: Message edited by: Ernest Friedman-Hill ]
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ernest is correct. This has been part of the language going all the way back to Oak. It is supposed to simplify dynamic compiling. If you are using a class in your class and that class hasn't been compiled yet, the compiler may be able to figure out where to look for it based on the source name.
 
Eric Lidell
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ernest and Thomas,
Thanx for the answers.
Simon
 
Eric Lidell
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought a source(class) had to be compiled already for it to be refered or used by another
class/program.when will dynamic compiling be used?
can u pls give me any example code /scenario?
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dynamic compiling is used by the compiler, not the JRE. If you write the following:
Test1.java

Test2.java

And then run "javac Test1.java", you will discover that the compiler compiled both Test1 and Test2 classes.
 
Eric Lidell
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Joel.
Btw,What does your motto mean?
 
Joel McNary
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Roughly translated, it reads:
"How much wood could a woodchuck chuck if a woodchuck could chuck wood?"
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I always thought it was the following.
"How much wood would a woodchuck chuck if a woodchuck could chuck wood?"
 
reply
    Bookmark Topic Watch Topic
  • New Topic