This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin Cookbook and have Ken Kousen on-line!
See this thread for details.
Win a copy of Kotlin Cookbook this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

How to calculate Java code?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I could not make a copy paste
but i don't understand how to calculate this java code
Thank you for your help
 
Sheriff
Posts: 6568
176
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "how to calculate this java code"?  Could you explain it in other words?  (I appreciate that English may not be your first language.)
 
Marshal
Posts: 67036
255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can simply copy'n'paste code onto the white area in the post window. The same place as where you write the questions. You can drag'n'drop code, too.
Have you been taught how to indent code? I think it should look like this:-There is an error, that line 19 is missing a final ;
Change all your ""s to " " so you can see the numbers separately, then run the code.
Write the values of x y z on paper and go through the code like this:-

line 99 x = 3 y = 4 2x + y = 10
line 100 ...

or similar. Be sure to write the current values on your paper, otherwise you will forget what they are and will become confused.
 
ronald deux
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
excuse me for my english, i'm not english, i'm using google translate
I know how to make a copy paste but it didn't work, I had to type the code by hand
I do calculations on paper to arrive at the same answers when you click on run but I can't
I give you the output, what interests me is to understand each line of code to arrive at the same results

3 0
1 2 4
4 3
5 2 4
8 1
5 9 4
 
Campbell Ritchie
Marshal
Posts: 67036
255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do what I said yesterday: write down the values for all the variables for each line. I think that is the only way you will understand the code.
 
Saloon Keeper
Posts: 6617
61
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code has a lot of things to try and confuse you. For example, the main method has a local variable 'x' and the mystery method has its own local variable 'x', these are not the same.
 
ronald deux
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i haven't thought about that, without the mystery variable, i can't get the same answers.
I did all kinds of calculations without the mystery variable and it gave nothing
it took my head this code,
I have a question about z--, it's the same as z-1 ???
 
Campbell Ritchie
Marshal
Posts: 67036
255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ronald deux wrote:. . . question about z--, it's the same as z-1 ???

No. i-- is the same as the original value of i. The value equal to i − 1 is not visible until later. That causes no end of confusion to inexperienced people. Look at this FAQ.
 
When it is used for evil, then watch out! When it is used for good, then things are much nicer. Like this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!