{"action":"created","comment":{"url":"https://api.github.com/repos/thoughtbot/til/pulls/comments/24944718","id":24944718,"diff_hunk":"@@ -0,0 +1,33 @@\n+Number Caching\n+--------------\n+\n+The following code creates 2 integer objects and compares them:\n+\n+```\n+public static void main(String[] args) {\n+  Integer a = 1000, b = 1000;\n+  System.out.println(a == b);\n+  Integer c = 100, d = 100;\n+  System.out.println(c == d);\n+}\n+```\n+\n+When ran, this block of code will print out:\n+\n+Expected output\n+---------------\n+```\n+false\n+false\n+```\n+\n+Actual output\n+-------------\n+```\n+false\n+true\n+```\n+\n+Reason\n+------\n+JVM caches objects for int values from -128 to 127 for some optimisation purposes. In this way, references of \"c\" and \"d\" is the same.","path":"java/integer-caching.md","position":33,"original_position":33,"commit_id":"392d5e9e607ee9bbcb501d8f57ac7950bcfdee4a","original_commit_id":"392d5e9e607ee9bbcb501d8f57ac7950bcfdee4a","user":{"login":"JoelQ","id":1006966,"avatar_url":"https://avatars.githubusercontent.com/u/1006966?v=3","gravatar_id":"","url":"https://api.github.com/users/JoelQ","html_url":"https://github.com/JoelQ","followers_url":"https://api.github.com/users/JoelQ/followers","following_url":"https://api.github.com/users/JoelQ/following{/other_user}","gists_url":"https://api.github.com/users/JoelQ/gists{/gist_id}","starred_url":"https://api.github.com/users/JoelQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoelQ/subscriptions","organizations_url":"https://api.github.com/users/JoelQ/orgs","repos_url":"https://api.github.com/users/JoelQ/repos","events_url":"https://api.github.com/users/JoelQ/events{/privacy}","received_events_url":"https://api.github.com/users/JoelQ/received_events","type":"User","site_admin":false},"body":"Does `==` compare by identity rather than by value?","created_at":"2015-02-18T21:54:35Z","updated_at":"2015-02-18T21:54:35Z","html_url":"https://github.com/thoughtbot/til/pull/67#discussion_r24944718","pull_request_url":"https://api.github.com/repos/thoughtbot/til/pulls/67","_links":{"self":{"href":"https://api.github.com/repos/thoughtbot/til/pulls/comments/24944718"},"html":{"href":"https://github.com/thoughtbot/til/pull/67#discussion_r24944718"},"pull_request":{"href":"https://api.github.com/repos/thoughtbot/til/pulls/67"}}},"pull_request":{"url":"https://api.github.com/repos/thoughtbot/til/pulls/67","id":29333293,"html_url":"https://github.com/thoughtbot/til/pull/67","diff_url":"https://github.com/thoughtbot/til/pull/67.diff","patch_url":"https://github.com/thoughtbot/til/pull/67.patch","issue_url":"https://api.github.com/repos/thoughtbot/til/issues/67","number":67,"state":"open","locked":false,"title":"Added integer caching","user":{"login":"rishirdua","id":4724852,"avatar_url":"https://avatars.githubusercontent.com/u/4724852?v=3","gravatar_id":"","url":"https://api.github.com/users/rishirdua","html_url":"https://github.com/rishirdua","followers_url":"https://api.github.com/users/rishirdua/followers","following_url":"https://api.github.com/users/rishirdua/following{/other_user}","gists_url":"https://api.github.com/users/rishirdua/gists{/gist_id}","starred_url":"https://api.github.com/users/rishirdua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishirdua/subscriptions","organizations_url":"https://api.github.com/users/rishirdua/orgs","repos_url":"https://api.github.com/users/rishirdua/repos","events_url":"https://api.github.com/users/rishirdua/events{/privacy}","received_events_url":"https://api.github.com/users/rishirdua/received_events","type":"User","site_admin":false},"body":"TIL JVM caches objects for int values from -128 to 127 for optimisation purposes","created_at":"2015-02-15T11:07:44Z","updated_at":"2015-02-18T21:54:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abe920d8948dd00b7d9416bf0904f23b2834d1ab","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thoughtbot/til/pulls/67/commits","review_comments_url":"https://api.github.com/repos/thoughtbot/til/pulls/67/comments","review_comment_url":"https://api.github.com/repos/thoughtbot/til/pulls/comments/{number}","comments_url":"https://api.github.com/repos/thoughtbot/til/issues/67/comments","statuses_url":"https://api.github.com/repos/thoughtbot/til/statuses/392d5e9e607ee9bbcb501d8f57ac7950bcfdee4a","head":{"label":"rishirdua:master","ref":"master","sha":"392d5e9e607ee9bbcb501d8f57ac7950bcfdee4a","user":{"login":"rishirdua","id":4724852,"avatar_url":"https://avatars.githubusercontent.com/u/4724852?v=3","gravatar_id":"","url":"https://api.github.com/users/rishirdua","html_url":"https://github.com/rishirdua","followers_url":"https://api.github.com/users/rishirdua/followers","following_url":"https://api.github.com/users/rishirdua/following{/other_user}","gists_url":"https://api.github.com/users/rishirdua/gists{/gist_id}","starred_url":"https://api.github.com/users/rishirdua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishirdua/subscriptions","organizations_url":"https://api.github.com/users/rishirdua/orgs","repos_url":"https://api.github.com/users/rishirdua/repos","events_url":"https://api.github.com/users/rishirdua/events{/privacy}","received_events_url":"https://api.github.com/users/rishirdua/received_events","type":"User","site_admin":false},"repo":{"id":30822434,"name":"til","full_name":"rishirdua/til","owner":{"login":"rishirdua","id":4724852,"avatar_url":"https://avatars.githubusercontent.com/u/4724852?v=3","gravatar_id":"","url":"https://api.github.com/users/rishirdua","html_url":"https://github.com/rishirdua","followers_url":"https://api.github.com/users/rishirdua/followers","following_url":"https://api.github.com/users/rishirdua/following{/other_user}","gists_url":"https://api.github.com/users/rishirdua/gists{/gist_id}","starred_url":"https://api.github.com/users/rishirdua/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishirdua/subscriptions","organizations_url":"https://api.github.com/users/rishirdua/orgs","repos_url":"https://api.github.com/users/rishirdua/repos","events_url":"https://api.github.com/users/rishirdua/events{/privacy}","received_events_url":"https://api.github.com/users/rishirdua/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rishirdua/til","description":"Today I Learned","fork":true,"url":"https://api.github.com/repos/rishirdua/til","forks_url":"https://api.github.com/repos/rishirdua/til/forks","keys_url":"https://api.github.com/repos/rishirdua/til/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rishirdua/til/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rishirdua/til/teams","hooks_url":"https://api.github.com/repos/rishirdua/til/hooks","issue_events_url":"https://api.github.com/repos/rishirdua/til/issues/events{/number}","events_url":"https://api.github.com/repos/rishirdua/til/events","assignees_url":"https://api.github.com/repos/rishirdua/til/assignees{/user}","branches_url":"https://api.github.com/repos/rishirdua/til/branches{/branch}","tags_url":"https://api.github.com/repos/rishirdua/til/tags","blobs_url":"https://api.github.com/repos/rishirdua/til/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rishirdua/til/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rishirdua/til/git/refs{/sha}","trees_url":"https://api.github.com/repos/rishirdua/til/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rishirdua/til/statuses/{sha}","languages_url":"https://api.github.com/repos/rishirdua/til/languages","stargazers_url":"https://api.github.com/repos/rishirdua/til/stargazers","contributors_url":"https://api.github.com/repos/rishirdua/til/contributors","subscribers_url":"https://api.github.com/repos/rishirdua/til/subscribers","subscription_url":"https://api.github.com/repos/rishirdua/til/subscription","commits_url":"https://api.github.com/repos/rishirdua/til/commits{/sha}","git_commits_url":"https://api.github.com/repos/rishirdua/til/git/commits{/sha}","comments_url":"https://api.github.com/repos/rishirdua/til/comments{/number}","issue_comment_url":"https://api.github.com/repos/rishirdua/til/issues/comments/{number}","contents_url":"https://api.github.com/repos/rishirdua/til/contents/{+path}","compare_url":"https://api.github.com/repos/rishirdua/til/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rishirdua/til/merges","archive_url":"https://api.github.com/repos/rishirdua/til/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rishirdua/til/downloads","issues_url":"https://api.github.com/repos/rishirdua/til/issues{/number}","pulls_url":"https://api.github.com/repos/rishirdua/til/pulls{/number}","milestones_url":"https://api.github.com/repos/rishirdua/til/milestones{/number}","notifications_url":"https://api.github.com/repos/rishirdua/til/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rishirdua/til/labels{/name}","releases_url":"https://api.github.com/repos/rishirdua/til/releases{/id}","created_at":"2015-02-15T08:47:54Z","updated_at":"2015-02-15T06:18:54Z","pushed_at":"2015-02-15T11:05:54Z","git_url":"git://github.com/rishirdua/til.git","ssh_url":"git@github.com:rishirdua/til.git","clone_url":"https://github.com/rishirdua/til.git","svn_url":"https://github.com/rishirdua/til","homepage":null,"size":2016,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"thoughtbot:master","ref":"master","sha":"55dc5cadd8ccacc37a8a765152b49a66a838bcb3","user":{"login":"thoughtbot","id":6183,"avatar_url":"https://avatars.githubusercontent.com/u/6183?v=3","gravatar_id":"","url":"https://api.github.com/users/thoughtbot","html_url":"https://github.com/thoughtbot","followers_url":"https://api.github.com/users/thoughtbot/followers","following_url":"https://api.github.com/users/thoughtbot/following{/other_user}","gists_url":"https://api.github.com/users/thoughtbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtbot/subscriptions","organizations_url":"https://api.github.com/users/thoughtbot/orgs","repos_url":"https://api.github.com/users/thoughtbot/repos","events_url":"https://api.github.com/users/thoughtbot/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtbot/received_events","type":"Organization","site_admin":false},"repo":{"id":29370487,"name":"til","full_name":"thoughtbot/til","owner":{"login":"thoughtbot","id":6183,"avatar_url":"https://avatars.githubusercontent.com/u/6183?v=3","gravatar_id":"","url":"https://api.github.com/users/thoughtbot","html_url":"https://github.com/thoughtbot","followers_url":"https://api.github.com/users/thoughtbot/followers","following_url":"https://api.github.com/users/thoughtbot/following{/other_user}","gists_url":"https://api.github.com/users/thoughtbot/gists{/gist_id}","starred_url":"https://api.github.com/users/thoughtbot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thoughtbot/subscriptions","organizations_url":"https://api.github.com/users/thoughtbot/orgs","repos_url":"https://api.github.com/users/thoughtbot/repos","events_url":"https://api.github.com/users/thoughtbot/events{/privacy}","received_events_url":"https://api.github.com/users/thoughtbot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thoughtbot/til","description":"Today I Learned","fork":false,"url":"https://api.github.com/repos/thoughtbot/til","forks_url":"https://api.github.com/repos/thoughtbot/til/forks","keys_url":"https://api.github.com/repos/thoughtbot/til/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thoughtbot/til/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thoughtbot/til/teams","hooks_url":"https://api.github.com/repos/thoughtbot/til/hooks","issue_events_url":"https://api.github.com/repos/thoughtbot/til/issues/events{/number}","events_url":"https://api.github.com/repos/thoughtbot/til/events","assignees_url":"https://api.github.com/repos/thoughtbot/til/assignees{/user}","branches_url":"https://api.github.com/repos/thoughtbot/til/branches{/branch}","tags_url":"https://api.github.com/repos/thoughtbot/til/tags","blobs_url":"https://api.github.com/repos/thoughtbot/til/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thoughtbot/til/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thoughtbot/til/git/refs{/sha}","trees_url":"https://api.github.com/repos/thoughtbot/til/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thoughtbot/til/statuses/{sha}","languages_url":"https://api.github.com/repos/thoughtbot/til/languages","stargazers_url":"https://api.github.com/repos/thoughtbot/til/stargazers","contributors_url":"https://api.github.com/repos/thoughtbot/til/contributors","subscribers_url":"https://api.github.com/repos/thoughtbot/til/subscribers","subscription_url":"https://api.github.com/repos/thoughtbot/til/subscription","commits_url":"https://api.github.com/repos/thoughtbot/til/commits{/sha}","git_commits_url":"https://api.github.com/repos/thoughtbot/til/git/commits{/sha}","comments_url":"https://api.github.com/repos/thoughtbot/til/comments{/number}","issue_comment_url":"https://api.github.com/repos/thoughtbot/til/issues/comments/{number}","contents_url":"https://api.github.com/repos/thoughtbot/til/contents/{+path}","compare_url":"https://api.github.com/repos/thoughtbot/til/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thoughtbot/til/merges","archive_url":"https://api.github.com/repos/thoughtbot/til/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thoughtbot/til/downloads","issues_url":"https://api.github.com/repos/thoughtbot/til/issues{/number}","pulls_url":"https://api.github.com/repos/thoughtbot/til/pulls{/number}","milestones_url":"https://api.github.com/repos/thoughtbot/til/milestones{/number}","notifications_url":"https://api.github.com/repos/thoughtbot/til/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thoughtbot/til/labels{/name}","releases_url":"https://api.github.com/repos/thoughtbot/til/releases{/id}","created_at":"2015-01-16T22:21:28Z","updated_at":"2015-02-18T21:39:23Z","pushed_at":"2015-02-18T21:01:46Z","git_url":"git://github.com/thoughtbot/til.git","ssh_url":"git@github.com:thoughtbot/til.git","clone_url":"https://github.com/thoughtbot/til.git","svn_url":"https://github.com/thoughtbot/til","homepage":null,"size":2016,"stargazers_count":2627,"watchers_count":2627,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":128,"mirror_url":null,"open_issues_count":21,"forks":128,"open_issues":21,"watchers":2627,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thoughtbot/til/pulls/67"},"html":{"href":"https://github.com/thoughtbot/til/pull/67"},"issue":{"href":"https://api.github.com/repos/thoughtbot/til/issues/67"},"comments":{"href":"https://api.github.com/repos/thoughtbot/til/issues/67/comments"},"review_comments":{"href":"https://api.github.com/repos/thoughtbot/til/pulls/67/comments"},"review_comment":{"href":"https://api.github.com/repos/thoughtbot/til/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/thoughtbot/til/pulls/67/commits"},"statuses":{"href":"https://api.github.com/repos/thoughtbot/til/statuses/392d5e9e607ee9bbcb501d8f57ac7950bcfdee4a"}}}}