473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Basic Question???

Why we can have only public class per java file? Is there any specific technical reson about that constrain? or any predefined JVM rule or else??

Thanx ...
Jun 6 '07 #1
3 1065
JosAH
11,448 Expert 8TB
Why we can have only public class per java file? Is there any specific technical reson about that constrain? or any predefined JVM rule or else??

Thanx ...
The compiler needs to be able to find classes that may not yet have been compiled.
If source code for a class can have any file name, or is hidden together with other
class sources, the compiler can't find it.

kind regards,

Jos
Jun 6 '07 #2
The compiler needs to be able to find classes that may not yet have been compiled.
If source code for a class can have any file name, or is hidden together with other
class sources, the compiler can't find it.

kind regards,

Jos

Jos yet its not clear....plz explain it in as simple way as possible...

thanx...
Jun 6 '07 #3
JosAH
11,448 Expert 8TB
Jos yet its not clear....plz explain it in as simple way as possible...

thanx...
Suppose you have two public classes A and B and also suppose an A object
creates or uses or refers to a B object.

When you compile A.java the compiler notices that a B object is used. Suppose
there's no B.class yet (B has not been compiled yet). The Javac compiler starts
searching for a source file B.java in order to compile it too. Suppose the name
could be anything; how is the compiler supposed to find the source for class B?

kind regards,

Jos
Jun 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Malcolm | last post by:
After some days' hard work I am now the proud possessor of an ANSI C BASIC interpreter. The question is, how is it most useful? At the moment I have a function int basic(const char *script,...
13
by: Pete | last post by:
I'm cross posting from mscom.webservices.general as I have received no answer there: There has been a number of recent posts requesting how to satisfactorily enable BASIC authorization at the...
5
by: Aussie Rules | last post by:
Hi, Having a mental block on this one. Have done it before but can't rack my brain on how... I have an object, with a bunch on property, and I add that object to a combo box. I want the...
4
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
3
by: Scott Stark | last post by:
Hello, I'm trying to get a better handle on OOP programming principles in VB.NET. Forgive me if this question is sort of basic, but here's what I want to do. I have a collection of Employee...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.