• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How do these classes work?

 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Steve for your Guide!!!



Varuna
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic