[program-java] Re: [program-l] Re: Java

  • From: "Corbett, James" <James.Corbett@xxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Fri, 28 Nov 2008 16:12:51 -0500

Ah, just tripped over something else.... If lets say Class1 is in
package1 and Class 1 is public then its scope is what Java says is less
than public because you can only really create a private instance of
Class1....

Now, lets say we have Class2 in package1 and the class is neither public
or private it's a default class.

class Class2 { 

}

...now Class2 is only visible with in package1.... Therefore private to
package1....

My question is: Why even bother with a private class unless of course
you are writing a private class with in a public or more over with in
the default class....

Jimmy says it's time to go home.

Jim 

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx] On Behalf Of J. R. Westmoreland
Sent: November 28, 2008 15:57
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Java

Maybe they should have called Main "global" since it is a special case.
<smile>
I recall reading a comment in a book somewhere that said, "Main is a
special case of a public class in java."
Maybe that fits better? <smile>

Regards,
J. R.

--------------------
J. R. Westmoreland
E-mail: jr@xxxxxxx


-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]

Sent: Friday, November 28, 2008 1:53 PM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Java

JR:

I see this, you see this, and Mark see's this.... But when you have a
turnip who's all ears and says wait a minute if the class is public and
the Main is also public then why is the first class less then public and
on and on it goes. I just find it odd that Sun would have broken such a
common concept. After all there were psychologists as part of the
development team employed to sort out issues such as this. One of the
prime directives of the creaters of Java was to keep the language
simple.

Anyway, just my few cents on the topic.

Jim 

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx] On Behalf Of J. R. Westmoreland
Sent: November 28, 2008 15:37
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Java

Hence, main is the class that is called at startup. Therefore, it is the
ultimate public class, you could say.
Example1 is a class which can be imported and used by other
packages/classes but can't be called by itself.
Thus, Example1 can be instangiated as an object with a Set and Get
method to its internals.
Finally, Main is the entry point to the project. It is like main() in
C/C++ and whatever they call the routine that gets control as the global
entry point in VB.

J. R.



--------------------
J. R. Westmoreland
E-mail: jr@xxxxxxx


-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx]

Sent: Friday, November 28, 2008 6:22 AM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Java

David:

Here is an example of a two class HelloWorld excersise.

package main;

/*
 *  entry point of application
 *  written by j. corbett
 *  oct. 31, 2008
 */

import ex1.Example1;

public class Main {

        private static Example1 hw = null;

        public static void main(String[] args) {

                hw = new Example1();
                System.out.println(hw.getHelloWorld());
        }

} // end of class

*************

package ex1;

public class Example1 {

        private String hw = "Hello World";

        public Example1() {

        }

        public void setHelloWorld(String s) {
                hw = s;
        }

        public String getHelloWorld() {
                return hw;
        }

} // end of class 

In this example class Main is the public interface to the project where
as class HelloWorld although public is really less than public but not
as far as private to the project.

I'm trying to phrase this entire wad of belly button putty in a manner
that explains the concept but doesn't leave a student scratching their
head and saying "but wait isn't HelloWorld public". 

I suppose it's a matter of semantics.

Jim  

-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx] On Behalf Of David Lant
Sent: November 28, 2008 05:02
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Re: Java

Hi Jim,

I don't know if the definitions of Public and otherwise coincide with
those of VB and VS, but I look upon Public as being something that is
accessible from outside the project.  Anything else is not.  Thus,
Private is only accessible from within the component in which it
resides.  Friend, in VB terms, is only accessible within the project,
but is accessible between components in the same project, and so on.

David Lant

Applications analyst
Tel: (01392) 382464




-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx
[mailto:program-l-bounce@xxxxxxxxxxxxx] On Behalf Of Corbett, James
Sent: 27 November 2008 20:33
To: program-java@xxxxxxxxxxxxx
Cc: program-l@xxxxxxxxxxxxx
Subject: [program-l] Java


...sorry for the cross posting but I thought y'all would find this
interesting.

I understand the following statement, but how would you explain it to a
newby....

"The java project file may only contain one public class but can contain
multiple classes with less than public access."

I'm wrestling with public verses private and now add less than
public.... Time for a stiff drink of Southern Comfort.

Jim 


James M. Corbett

A / Technical Specialist
GST / HST Micro Development
875 Heron Rd / Ottawa / Ontario

(613) 941-1338
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq
** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts:

  • » [program-java] Re: [program-l] Re: Java - Corbett, James