• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic