File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How do these classes work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do these classes work?" Watch "How do these classes work?" New topic
Author

How do these classes work?

Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167




The above classes are from a book I am reading.
Please tell me in the constructor of the LogEntry class, the tokenize() of the LoglineTokenizer class is called.When it is called the parameters logline,dataValues are passed.In the tokernize() method the tokens.countTokens()==dataLine.length is checked.How can this become true?.How are these two countTokens and dataLine.length become equal?.The array dataValue is passed to the tokenize method and it is received by the dataLine array local parameter, the changes done in the dataLine are reflected in the dataValue array.Are arrays passed by value in Java as default?





Thanks Varuna
[ November 06, 2008: Message edited by: Varuna Seneviratna ]

Varuna Seneviratna
Rory Marquis
Ranch Hand

Joined: Nov 03, 2008
Posts: 48
They will be true if the "longline" String that is passes in has 8 separated entries in it.

The array that is passed into the LoglineTokenizer is a reference to the Array object "dataValues" (which is an Array object of privative int values) that is created in the LogEntry constructor before it is passed in.

HTH
Ror
[ November 06, 2008: Message edited by: Rory Marquis ]
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 4181
    
  21

Also, you ask:
the changes done in the dataLine are reflected in the dataValue array.Are arrays passed by value in Java as default?


This is a key concept in Java, please read: Call by Reference Vs Call by Value in the JavaRanch FAQ.


Steve
Varuna Seneviratna
Ranch Hand

Joined: Jan 15, 2007
Posts: 167
Thanks Steve for your Guide!!!



Varuna
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do these classes work?