Skip to content

Instantly share code, notes, and snippets.

@sergiilagutin
Created January 22, 2018 10:12
Show Gist options
  • Save sergiilagutin/8f85c64b261d527253e77cdeb4e8e5dd to your computer and use it in GitHub Desktop.
Save sergiilagutin/8f85c64b261d527253e77cdeb4e8e5dd to your computer and use it in GitHub Desktop.
val str = "first string"
val field = classOf[String].getDeclaredField("value")
field.setAccessible(true)
val value = field.get(str).asInstanceOf[Array[Char]]
value(0) = 'W'
value(1) = 'o'
str // "Worst string"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment