java beginnings

C

cusickgeorge

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
 
A

Andrew Thompson

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;

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.

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

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1
 
R

Roedy Green

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


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

}

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 ;
}
}
 
G

GeorgeTrevelyan

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;
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.

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

--
Andrew Thompsonhttp://www.athompson.info/andrew/

Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1- Hide quoted text -

- Show quoted text -

THANKS FOR YOUR HELP, George
 
R

Roedy Green

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.
 
L

Lew

Roedy said:
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.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Roedy said:
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.

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

Arne
 
R

Roedy Green

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.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

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

I *prefer* surrounding with asterisks.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top