Results 1 to 5 of 5
Thread: Reference !
- 12-26-2012, 01:11 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 76
- Rep Power
- 0
Reference !
In the following code:
class Node
{
int iData; // data used as key value
double fData; // other data
node leftChild; // this node’s left child
node rightChild; // this node’s right child
}
I understand that Node is a class and when we want to refer to a variable we can use the format "type name " format where type is the name of the class and name is the name of the variable.
So,In the above code, node leftchild is used where leftchild is a variable of type node. Why the node is not written as "Node" as N is capital while defining the class name. Shouldn't it be "Node leftchild" or "Node rightchild". Please clarify and thanks in advance.
PS: the above code is an excerpt from a book.
- 12-26-2012, 01:34 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: Reference !
Yes you are right.
Code Conventions for the Java Programming Language: 9. Naming Conventions
"Class names should be nouns, in mixed case with the first letter of each internal word capitalized. "
And if the same node is meant as the class itself, then more than ever.
p.s.: Burn the book :)
- 12-26-2012, 01:51 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
Re: Reference !
It probably should be a 'Node' type instead of 'node' (unless there's something going on, not shown in the code snippet). That's the trouble with a lot of those books nowadays: those authors are only in it for the money and those books are full of crappy code. Also the names 'iData' and 'fData' are lousy imho, better change them to 'key' and 'data' instead ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-26-2012, 02:02 PM #4
Member
- Join Date
- Nov 2011
- Posts
- 76
- Rep Power
- 0
Re: Reference !
Thanks a lot for your answer guys.
Any good Java book recommended for algorithms?
- 12-26-2012, 03:37 PM #5
Re: Reference !
You asked this question two minutes earlier in Constructor Not Used ?
Please go through the Forum Rules, particularly the second paragraph.
db
THREAD CLOSEDWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Reference object
By clj89 in forum New To JavaReplies: 5Last Post: 10-22-2011, 11:32 PM -
How to change value by reference?
By chris83190@hotmail.com in forum New To JavaReplies: 5Last Post: 05-08-2011, 07:52 AM -
Don't pass by reference
By Lyven in forum Advanced JavaReplies: 6Last Post: 11-16-2009, 06:06 PM -
Object and reference
By katie in forum New To JavaReplies: 2Last Post: 10-19-2009, 03:45 PM -
Pass-by-reference
By popjava in forum New To JavaReplies: 1Last Post: 10-19-2009, 03:45 PM


LinkBack URL
About LinkBacks


Bookmarks