Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

(Beginner Question) Prefix and Postfix Increment Operators

Featured Replies

Hello everyone,

I would like to begin this by mentioning that I am learning Java through the app SoloLearn. I have understood most of what I have covered (which is the entire Basics section) but I did not understand something involving Prefix and Postfix Increment (+) operators.

 

I don't understand why in this example the result is 35

int x=34;

int y= ++x

 

but in this it is still 34.

int x=34;

int y= x++;

 

Can someone help me understand why this is? Thank you!

 

 

5 minutes ago, PixelToast said:

Hello everyone,

I would like to begin this by mentioning that I am learning Java through the app SoloLearn. I have understood most of what I have covered (which is the entire Basics section) but I did not understand something involving Prefix and Postfix Increment (+) operators.

 

I don't understand why in this example the result is 35

int x=34;

int y= ++x

 

but in this it is still 34.

int x=34;

int y= x++;

 

Can someone help me understand why this is? Thank you!

 

 

Because with prefix x is incremented first then the result is assigned to y

With postfix the value of x is assigned to y, then x is incremented

 

int y= ++x 

FIRST INCREMENT X THEN ASSIGN THE VALUE OF X TO Y:

x = x +1 // First increment x

int y = x; // Then assign the value of x to y

 

int y= x++

FIRST ASSIGN THE VALUE OF X TO Y THEN INCREMENT X:

int y = x; // First assign the value of x to y

x = x+1; // Then increment x

 

 

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.