The align() method

When you define a multiline string value, you might choose to format the string against the left margin or align it with the indentation used by the code. The string values are stored with the margin intact. The align() method will provide incidental indentation support; it will strip off any leading or trailing blank lines, then justify each line, without losing the indentations.

The following is an example:

String comment =  
       `one  
          of 
                  my 
           favorite 
               lang 
                   feature 
       from Amber(!)  
`.align(); 
System.out.println(comment); 

The output of the preceding code is as follows:

one  
   of 
           my 
    favorite 
        lang 
            feature 
from Amber(!)  
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.189.186