+ 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 Answers
+ 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