🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #16579

Re: beginners java lang questions

#16579
From: Steve Schafer (TeamB)
Date: Thu, 28 Jan 1999 00:00
39 lines
1851 bytes
On Wed, 27 Jan 1999 22:44:07 GMT, info@nbinc.com (info@nbinc.com)
wrote:

>1. When looking at java code, one sees many statements like:
>	xclass xobject=new xclass()
>isnt this use of the first "xclass" redundant? the new object HAS to
>be of the type xclass, so why were the purposes of instantiation &
>declaration separated?

This is a combination of two separate things, a declaration:

 xclass xobject; // declares xobject to be a variable of type xclass

and an initialization:

 xobject = new xclass(); // creates a new instance of xclass

This example shows why it's not redundant:

 Window w = new Dialog(parent);

That is, a variable of type X can point to an instance of class X, but
it can alternatively point to an instance of a descendant class.

>2. why cant properties of components be accessed directly eg cant say:
>	buttonControl1.Label="some text"
>have to say:
>	buttonControl1.setLabel("some text")

Because Java isn't Delphi. :) In languages like Delphi and Visual
Basic, an attempt to set a property:

 MyButton.Caption := 'Some text';

actually causes the invocation of a method (SetCaption in this case).
The only difference with Java is that this method invocation is
explicit, and doesn't happen magically behind the scenes.

-Steve
Technical Details
Message-ID: <36bbc0ab.15986372@90.0.0.40>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36af90c4.1869276@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,41acd0212bd83621
X-Google-Attributes: gidf74b3,public
From: pandeng@telepath.com (Steve Schafer (TeamB))
Subject: Re: beginners java lang questions
Date: 1999/01/28
Message-ID: <36bbc0ab.15986372@90.0.0.40>
X-Deja-AN: 437769099
Content-Transfer-Encoding: 7bit
References: <36af90c4.1869276@forums.borland.com>
Content-Type: text/plain; charset=us-ascii
Organization: TeamB
Mime-Version: 1.0
Reply-To: pandeng@telepath.com
Newsgroups: borland.public.jbuilder.java.language