Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

[Sybex] In the book OCA8 possible errata at Chapter 2, page 87

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, two discalmers. One, I believe I have an old version of the book, so possibility that it was already fixed exists (although I didn't see this in errata on the website). And second, this really doesn't affect understanding of the material, but might confuse some people who will go through the code line by line (or I just might have wrong understanding).

Let me give you the whole code for the context:

As you can see, each number has tabulation added after it and in the provided output the last 7 is shifted a bit like it was affected by 12 before it
5     2     1     3
3     9     7     9
5     7     12     7


But my understanding of how tabulation works is that 7 should be aligned with rest of numbers in its column and the output should be like this
5     2     1     3
3     9     7     9
5     7     12    7
 
Marshal
Posts: 79637
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it on JShell on Ubuntu Focal/bash and it worked first time. I don't think there is a problem with the code. Please give us more details about your terminal/command line.Why are you mixing an ordinary for loop and a for‑each loop?
 
Igor Dvorkin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Campbell!

That's not my code, it's an example from the book. In my terminal it works without dis-alignment as well. Screenshot from the book in attachment.
Sorry for not being clear enough that the output is taken from the book too.
chrome_MaqEDhkFmM.png
OCA8 chapter 2, page 87
OCA8 chapter 2, page 87
 
Campbell Ritchie
Marshal
Posts: 79637
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah! That does look like a typo; which edition of the book is it? Is it paper/pdf/Kindle/etc?
 
Igor Dvorkin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a pdf version, no idea if it's the same in paper version
 
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Added to errata. Conveniently the extra space is not in the Java 11 edition of this books. So it did get corrected in our editing process the second book around!
 
Igor Dvorkin
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, awesome!
Any chance changing Dvorkkin/a to Dvorkin with one "k" and no "a"?
 
Jeanne Boyarsky
author & internet detective
Posts: 41967
911
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Got rid of the extra "k". Sorry about that.

The "/a" was, well that page is HTML. (The Java 11 page is a proper blog table. But I can't be bothered to convert the old page)
 
reply
    Bookmark Topic Watch Topic
  • New Topic