Title: Demonstrate pre/ post increment operators better · Issue #149 · java/devjava-content · GitHub
Open Graph Title: Demonstrate pre/ post increment operators better · Issue #149 · java/devjava-content
X Title: Demonstrate pre/ post increment operators better · Issue #149 · java/devjava-content
Description: The second code snippet from the Unary section does not illustrate the core difference between the pre and post increment operators well (++i vs i++): https://dev.java/learn/language-basics/using-operators/#unary Both System.out.println(...
Open Graph Description: The second code snippet from the Unary section does not illustrate the core difference between the pre and post increment operators well (++i vs i++): https://dev.java/learn/language-basics/using-o...
X Description: The second code snippet from the Unary section does not illustrate the core difference between the pre and post increment operators well (++i vs i++): https://dev.java/learn/language-basics/using-o...
Opengraph URL: https://github.com/java/devjava-content/issues/149
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Demonstrate pre/ post increment operators better","articleBody":"The second code snippet from the Unary section does not illustrate the core difference between the pre and post increment operators well (++i vs i++):\nhttps://dev.java/learn/language-basics/using-operators/#unary\n\nBoth \n`System.out.println(++i);`\nand\n`System.out.println(i++);`\nproduce the same output so it might be confusing as to what is the actual difference.\n\n\nI would suggest replacing it with something along the lines of\n```\nint i = 3;\n\ni++;\n// prints \"i = 4\"\nSystem.out.println(\"i = \" + i);\n\n++i;\n// prints \"i = 5\"\nSystem.out.println(\"i = \" + i);\n\nint j = ++i;\n// prints \"i = 6\"\nSystem.out.println(\"i = \" + i);\n// prints \"j = 6\"\nSystem.out.println(\"j = \" + j);\n\nint k = i++;\n// prints \"i = 7\"\nSystem.out.println(\"i = \" + i);\n// prints \"k = 6\"\nSystem.out.println(\"k = \" + k);\n```\n\n","author":{"url":"https://github.com/Locust1","@type":"Person","name":"Locust1"},"datePublished":"2025-04-05T19:09:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/149/devjava-content/issues/149"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3cd58416-4f7c-6202-f0d9-a6816c5eb209 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8BA0:2A6D22:959696:C25B63:697703BE |
| html-safe-nonce | 1a0bf30ccfc211f43fe98ff67559d4101616be39e3d23bc4db21e100cce9abd7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QkEwOjJBNkQyMjo5NTk2OTY6QzI1QjYzOjY5NzcwM0JFIiwidmlzaXRvcl9pZCI6Ijg5MDE1MzU5MDk5MDgyNTE1ODIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cef35dc59d40d70396c75f04e5951c9cc66804c91dcb475cf9c9303b11f24084 |
| hovercard-subject-tag | issue:2974442728 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/java/devjava-content/149/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c0720a0c8ccd891fe4c8637909934109c057b7fb9a45a105537424ec0b30f6cc/java/devjava-content/issues/149 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c0720a0c8ccd891fe4c8637909934109c057b7fb9a45a105537424ec0b30f6cc/java/devjava-content/issues/149 |
| og:image:alt | The second code snippet from the Unary section does not illustrate the core difference between the pre and post increment operators well (++i vs i++): https://dev.java/learn/language-basics/using-o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Locust1 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 01d198479908d09a841b2febe8eb105a81af2af7d81830960fe0971e1f4adc09 |
| turbo-cache-control | no-preview |
| go-import | github.com/java/devjava-content git https://github.com/java/devjava-content.git |
| octolytics-dimension-user_id | 126123820 |
| octolytics-dimension-user_login | java |
| octolytics-dimension-repository_id | 614090520 |
| octolytics-dimension-repository_nwo | java/devjava-content |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 614090520 |
| octolytics-dimension-repository_network_root_nwo | java/devjava-content |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f752335dbbea672610081196a1998e39aec5e14b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width