+ 1

I don’t under stand

int i = 1; System.out.println(3+(—1)); Guys is this give output??? It’s give me error Maybe my teacher write it rong ? In java

20th Oct 2020, 10:13 AM
STOP
STOP - avatar
17 odpowiedzi
+ 6
Replace --1 with --i . Then it'll be ok ,otherwise what is the use of i.
20th Oct 2020, 10:18 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 5
--1 is wrong in your code. Decrement operator can be used with variables only.
20th Oct 2020, 10:17 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 5
Yes
20th Oct 2020, 10:20 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 5
Okk. All the best
20th Oct 2020, 10:28 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 4
I dnt knw. It is U who post the code . U can modify it according to ur desires for ur required output
20th Oct 2020, 10:24 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 2
See... Whenever some number is incremented or decremented on that same instant.. Rather if you use the value of i for the next step....you will get the expected result... If not clear then you may DM me
21st Oct 2020, 4:45 AM
The INDIAN
The INDIAN - avatar
+ 1
the answer is 3 right?
20th Oct 2020, 10:19 AM
STOP
STOP - avatar
+ 1
You can't pre-or-post decrement/increment constant values.
21st Oct 2020, 4:13 AM
Sonic
Sonic - avatar
+ 1
1. No, maybe you type it wrong.. There is unknown character in your syntax that java not usually use it What is it? Your minus.. (-) Use the short minus.. (-) Not the long one(—) neither the med one..(–) Done.. Your syntax, bug, and error fixed.. Always try to read your own error in console, because it sometimes tell you which line or syntax is wrong..
21st Oct 2020, 8:56 AM
El Roy Situmorang
+ 1
You cant write --1 on a number!! You can use this on variable -> --i 3+(-1) result is 2 3+(--i) result is 3 in your case. https://www.sololearn.com/learn/Java/2141/
21st Oct 2020, 4:09 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
0
https://code.sololearn.com/c58C8zJuewzm/?ref=app
20th Oct 2020, 10:15 AM
STOP
STOP - avatar
20th Oct 2020, 10:17 AM
STOP
STOP - avatar
0
why we give int i =1 when we dont use it on the output!
20th Oct 2020, 10:18 AM
STOP
STOP - avatar
0
why there is ( int i =1 1 here What is its use if it does not help us in the output and print order?
20th Oct 2020, 10:21 AM
STOP
STOP - avatar
0
my teacher give me this on exam , i answerd 3 for me the mark is not the same important of understand
20th Oct 2020, 10:27 AM
STOP
STOP - avatar
0
so i come here to ask and understand
20th Oct 2020, 10:27 AM
STOP
STOP - avatar
0
i= 1( - -1) = +1 3 + (- -1) = 3+1 = 4 is this solution is true???
20th Oct 2020, 12:15 PM
STOP
STOP - avatar