+ 2
System.out.print(result) - why not "result"?
When coding an operator, for example +, I had to write: int x =2 , y =4 ; int sum = x + y ; System.out.print(result); why not ....("result") because, we know if we are to print a string of words, the words must be included in " "
12 Answers
+ 6
Your variable 'result' isnt declared.
int x=2, y=4;
int result = x+y;
System.out.println(result);
or
int x=2, y=4;
int sum= x+y;
System.out.println("Result: " + sum);
+ 5
Syastem.out.println("sum");
+ 2
System.out.print(”Result: ” + sum);
+ 2
"result" will simply print "result", result will print the value of result
+ 2
Dude, your "result" is a string and if you print it, it gives "result". You have to declare that. And here SOP will be (sum) not (result). Thank you.
+ 2
because here result is a value not a string
+ 1
result isn't declared so it will shown a error
+ 1
You need to include this in "", because result variable doesn't exist.
How answered previous, it will crush.
0
1st: sum is the name of your variable
2nd: (sum) but not ("sum") cos' everything in the "" is considered String or as you may realize "text"
0
We don't "" on numbers 'result' is a value or a number.
0
first you declare the variable result
- 1
java