gString in the middle of a line


/ Published in: Groovy
Save to your folder(s)

********************************************************************************
* *
* Andreas writes groovy scripts! Jana corrects the mistakes! ;-) *
* *
********************************************************************************


Copy this code and paste it in your HTML
  1. def star = '*'
  2. def lineof80stars = star * 80
  3.  
  4. def myName = 'Andreas'
  5. def mySister = 'Jana'
  6. def gString = "$myName writes groovy scripts! $mySister corrects the mistakes! ;-)"
  7. def centerText = star + gString.center(78) + star
  8. def centerEmptyLine = star + " ".center(78) + star
  9. def newline = '\n'
  10.  
  11. print lineof80stars + newline
  12. println centerEmptyLine
  13. println centerText
  14. println centerEmptyLine
  15. print lineof80stars

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.