• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do these classes work?

 
Varuna Seneviratna
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




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 ]
 
Rory Marquis
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4181
21
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Varuna Seneviratna
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Steve for your Guide!!!



Varuna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic