• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sybex Practice Tests 17 - Chapter 1 - Page 21

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I think there is a formatting error on question 66 on Kindle.

Code appears in the following way and the answer says that there are both incidental and essential whitespace. I can see only essential whitespace.
Am I misunderstood concept of incidental whitespace or am I right?

 
Marshal
Posts: 79240
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I don't know whether there is a formatting error or not, but you can find the definition of text blocks in the JLS (=Java® Language Specification).

Let's try the code on JShell:-

Campbell's JShell wrote:jshell>                                                       var block = """
  ...>                                      green
  ...>                                        yellow
  ...>                                      """;
block ==> "green\n  yellow\n"

jshell> block
block ==> "green\n  yellow\n"

jshell> System.out.print(block);
green
 yellow

Notice the incidental whitespace, which is that to the left of the """ delimiters, has been removed. Only the rightmost two spaces in line 3 are essential whitespace, and those remain. Note that the line end after line 3 is preserved.
 
Matthew Phoenix
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As the book says the incidental whitespace is the space on the left of the line "draw" by the last leftmost character. In both the example (the one that I posted and the one from Jshell). The immaginary  vertical line to draw is on the same level of the "g" of green and """. I cannot see other whitespace on the left, that's why I don't think there is an incidental whitespace.
If I miss or misunderstand something from your answer please let me know.

Thanks in advance
 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the print book it says



Unfortunately, we have no control of the formatting on Kindle.
 
Matthew Phoenix
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jeanne Boyarsky wrote:In the print book it says



Unfortunately, we have no control of the formatting on Kindle.



I think I misunderstood the essential whitespace explanation in the book. In this example "the line draw by the last leftmost character" is the one immediately before then g of green? Am I right ?
Because to calculate the incidental whitespace usually I took into account a line draw by the triple """.
 
Jeanne Boyarsky
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Matthew Phoenix wrote:I think I misunderstood the essential whitespace explanation in the book. In this example "the line draw by the last leftmost character" is the one immediately before then g of green? Am I right ?


Yes! You are correct
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic