I don’t under stand | SoloLearn: Learn to code for FREE!

+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

10/20/2020 10:13:54 AM

STOP

19 Answers

New Answer

+6

Replace --1 with --i . Then it'll be ok ,otherwise what is the use of i.

+5

--1 is wrong in your code. Decrement operator can be used with variables only.

+5

+5

Okk. All the best

+4

I dnt knw. It is U who post the code . U can modify it according to ur desires for ur required output

+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

+1

the answer is 3 right?

+1

You can't pre-or-post decrement/increment constant values.

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

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

0

https://code.sololearn.com/c58C8zJuewzm/?ref=app

0

but when i write i instead 1 https://code.sololearn.com/c089BdaEB0Sh/?ref=app

0

why we give int i =1 when we dont use it on the output!

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?

0

my teacher give me this on exam , i answerd 3 for me the mark is not the same important of understand

0

so i come here to ask and understand

0

i= 1( - -1) = +1 3 + (- -1) = 3+1 = 4 is this solution is true???

0

Tutorial for simple logo out https://youtu.be/9BaYOMqV-rE