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 / October 2007

Tip: Looking for answers? Try searching our database.

java beginnings

Thread view: 
cusickgeorge@hotmail.com - 29 Sep 2007 19:20 GMT
I am new to programming in Java, hope someone can help.
Please look at the following code:

package George;

public class TestCat
{
  public static void main(String[] args)
  {
     int[] car1 = {5, 4};
     int[] maker1 = {3, 6, 6, 2};
     Cat num1 = new Cat(car1, maker1);
_____________________________________
This calls a new class Cat as follows . . . .
_____________________________________
package George;

public class Cat
{
  private int[] carId;
  private int[] makerId;

  /**
   * Creates a new instance of Cat
   */
  public Cat(int[] anCarId, int[] aMakerId)
  {

  }

Question, the Cat class uses two array arguments and uses them to set
value of car identifier and maker identifier.
How can it do this.  What does TestCat send to Cat to start the
process.

Any help appreciated
Andrew Thompson - 29 Sep 2007 20:12 GMT
>I am new to programming in Java, hope someone can help.

A good group for beginners in Java is comp.lang.java.help.

> Please look at the following code:

Sure.

>package George;
>
[quoted text clipped - 25 lines]
>Question, the Cat class uses two array arguments and uses them to set
>value of car identifier and maker identifier.

Questions in English, generally end with a '?'.
That makes it easier for people scanning the code,
to quickly identify the question.

But as to the answer, I am guessing it is as simple as..
 carId = anCarId;
 makerId = aMakerId;
..within the constructor of Cat.

BTW, how are Cats (felines, puss-puss) related to
Cars (automobiles)?

Another note, while I am here, is that normal
Java nomenclature suggests all package names
should be entirely lower case, so 'George' should
be called 'george'.  If you change it, you will also
need to change the directory name in which the
source resides.

HTH

Signature

Andrew Thompson
http://www.athompson.info/andrew/

GeorgeTrevelyan - 30 Sep 2007 10:48 GMT
> cusickgeo...@hotmail.com wrote:
> >I am new to programming in Java, hope someone can help.
[quoted text clipped - 62 lines]
>
> - Show quoted text -

THANKS FOR YOUR HELP, George
Andrew Thompson - 30 Sep 2007 13:56 GMT
>> cusickgeo...@hotmail.com wrote:
...
>THANKS FOR YOUR HELP, George

No worries, but please note there is no need to SHOUT
at us.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Roedy Green - 01 Oct 2007 00:22 GMT
>No worries, but please note there is no need to SHOUT
>at us.

The reason to avoid upper case is nothing to do with hurting ear
drums.  It is just that lower case is faster and easier to read. You
should reserve upper case when you really mean the emphasis, and keep
the phrase short.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Lew - 01 Oct 2007 00:31 GMT
> The reason to avoid upper case is nothing to do with hurting ear
> drums.  It is just that lower case is faster and easier to read. You
> should reserve upper case when you really mean the emphasis, and keep
> the phrase short.

I beg to differ.  The common interpretation of all upper-case letters in a
mixed-case environment is loud volume.  Being responsible for this common
interpretation, a writer will avoid using all upper-case phrases except where
they intend to convey shouting.  Likewise they will resort to it when they
wish to convey shouting, despite that it will cause people to read more slowly
and with more difficulty.  As with the aural version, one will avoid shouting
in polite company.

Either way, whether you call it "shouting" or "emphasis", clearly you and
Andrew are in agreement as to the wiser course of action: to cap, or not to
cap?  That is the question.

Signature

Lew

Arne Vajhøj - 01 Oct 2007 00:31 GMT
>> No worries, but please note there is no need to SHOUT
>> at us.
[quoted text clipped - 3 lines]
> should reserve upper case when you really mean the emphasis, and keep
> the phrase short.

It is traditional usenet convention to consider all uppercase
for shouting.

Arne
Roedy Green - 01 Oct 2007 02:51 GMT
>It is traditional usenet convention to consider all uppercase
>for shouting.

Since you can't use <i> or <b> for emphasis, what else do you have
besides all caps?

Some used back in the BIX days:

1.  this is a _very_ important word.

2. this is a   v   e   r   y   important word

The problem with both conventions is they will likely foul up search
engines and local searches.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Arne Vajhøj - 01 Oct 2007 02:57 GMT
>> It is traditional usenet convention to consider all uppercase
>> for shouting.
>
> Since you can't use <i> or <b> for emphasis, what else do you have
> besides all caps?

I *prefer* surrounding with asterisks.

Arne
Arne Vajhøj - 01 Oct 2007 02:57 GMT
>>> It is traditional usenet convention to consider all uppercase
>>> for shouting.
[quoted text clipped - 3 lines]
>
> I *prefer* surrounding with asterisks.

Which BTW in some newsreaders are shown in bold.

Arne
Lew - 01 Oct 2007 04:31 GMT
Roedy Green wrote:
>>> Since you can't use <i> or <b> for emphasis, what else do you have
>>> besides all caps?

>> I *prefer* surrounding with asterisks.

> Which BTW in some newsreaders are shown in bold.

Those same newsreaders will transform text enclosed in /forward-slash/
characters into /italics/.

Signature

Lew

Roedy Green - 30 Sep 2007 02:54 GMT
>public class Cat
>{
[quoted text clipped - 8 lines]
>
>   }

I think you are asking how does the Cat constructor record for
posterity the values of the parameters.

 public Cat(int[] anCarId, int[] aMakerId)
  {
  this.carId = anCarId,
  this.makerId = aMakerId;
  }

Usually you name your parm and instance variable
the same like this:

public class Cat
{
 private int[] carId;
 private int[] makerId;

 public Cat(int[] carId , int[] makerId )
  {
  this.carId = carId ,
  this.makerId = makerId ;
  }
}
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



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.