Skip to content

Instantly share code, notes, and snippets.

@claudemartin
Forked from kaecy/.java
Last active February 8, 2018 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudemartin/b5693a7f30d31c15899582d3e8c02a30 to your computer and use it in GitHub Desktop.
Save claudemartin/b5693a7f30d31c15899582d3e8c02a30 to your computer and use it in GitHub Desktop.
public static void main(String args[]) {
String str = "abc";
byte[] cstr = str.getBytes();
cstr[0] = 'b';
System.out.println(new String(cstr));
System.out.println(str); // still "abc" -> it has not changed
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment